diff --git a/Audits/participated.txt b/Audits/participated.txt index 258391e..b5c7158 100644 --- a/Audits/participated.txt +++ b/Audits/participated.txt @@ -15,6 +15,9 @@ https://codehawks.cyfrin.io/c/2025-04-rock-paper-scissors - Rock paper scissors https://codehawks.cyfrin.io/c/2025-05-hawk-high - school project ( first flight ) +--------------------------------------------------------------------------------------------------- + + forge install https://github.com/foundry-rs/forge-std --no-commit && forge install https://github.com/OpenZeppelin/openzeppelin-contracts --no-commit // revise diff --git a/Ethereum/DEFI/AMM.txt b/Ethereum/DEFI/AMMOrUniswap.txt similarity index 64% rename from Ethereum/DEFI/AMM.txt rename to Ethereum/DEFI/AMMOrUniswap.txt index 92cde26..43b932d 100644 --- a/Ethereum/DEFI/AMM.txt +++ b/Ethereum/DEFI/AMMOrUniswap.txt @@ -1,30 +1,49 @@ + +----------------------------------- Uniswap v2 ----------------------------------------- +-> the bigger the curve , the better price you will get when we do a trade ( more liquidity) +-> Three main contracts - Factory , Router and pair contracts + - Factory is used to deploy the pair contract + - Router is the intermediate contract between the user and the pair contract + - users can still directly interact with the pair contract but suggested to use the router contract so it will automate some functionalities and checks +-> swap fee was charged on the incoming token into the pool +-> swapExactTokensForTokens - I want to spend exactly X tokens, give me at least Y tokens out +-> swapTokensForExactTokens - I want to receive exactly Y tokens, and I'm willing to spend up to X tokens to get it +-> Uniswap uses TWAP - Time weighted average price +-> Uniswap provides flash swaps using the pair contracts just like the flash loans + + + + +-------------------------------- Constant Product AMM ----------------------------------- -> AMM - x * y = k ( x = Asset A , y = Asset B , k = Constant value ) -> price of Asset x = x / y -> price of Asset y = y / x From the above equations we can get the below two equations -> reserve of x**2 = K / price of x -> reserve of y**2 = K * price of y --> Our share in the liquidity is = liquidity of ours / current total liquidity +-> Our share in the liquidity is = liquidity of ours / current total liquidity ( LP tokens ) -> When liquidity is added, K changes because the total pool size has increased—but each liquidity provider's share is then calculated as a fraction of the new total liquidity -> x*y = (x + deltax) * (y - deltay) --> At a price of 4000 USDT/ETH: ( invested 1 eth at 2000 price ) -Pool Reserves: Approximately 0.7071 ETH and 2828.43 USDT. + +Below Example was from LP token holder perspective +-> At a price of 4000 USDT/ETH: ( added 1 eth at 2000 price into the pool ( 1 eth , 2000 usdt ) ) +Pool Reserves: Approximately 0.7071 ETH and 2828.43 USDT. ( x * y = ~2000) Total Value upon Removal: ~5656.86 USDT. Impermanent Loss: ~343.14 USDT compared to simply holding. At a price of 5000 USDT/ETH: -Pool Reserves: Approximately 0.6325 ETH and 3162.28 USDT. +Pool Reserves: Approximately 0.6325 ETH and 3162.28 USDT. ( x * y = ~2000) Total Value upon Removal: ~6324.78 USDT. Impermanent Loss: ~675.22 USDT compared to holding. At 1000 USDT/ETH: -Pool Reserves: ≈ 1.4142 ETH and ≈ 1414.21 USDT +Pool Reserves: ≈ 1.4142 ETH and ≈ 1414.21 USDT ( x * y = ~2000) Total Value: ≈ 2828.42 USDT If Held: 3000 USDT Impermanent Loss: ≈ 171.58 USDT At 500 USDT/ETH: -Pool Reserves: 2 ETH and 1000 USDT +Pool Reserves: 2 ETH and 1000 USDT ( x * y = ~2000) Total Value: 2000 USDT If Held: 2500 USDT Impermanent Loss: 500 USDT diff --git a/Ethereum/EIPorERC.txt b/Ethereum/EIPorERC.txt index 0caa77a..ed7107f 100644 --- a/Ethereum/EIPorERC.txt +++ b/Ethereum/EIPorERC.txt @@ -40,6 +40,8 @@ -> ERC - 7715 Grant permissions for Wallets -> erc-1155 - what are semi fungible token + - A single ERC-1155 contract can manage multiple token types, including fungible, non-fungible, and semi-fungible tokens + - ERC-1155 can represent semi-fungible tokens, which are essentially fungible tokens that can be converted into non-fungible tokens under certain conditions -> EIP-3529: Reduction in refunds @@ -56,6 +58,8 @@ -> EIP-7863 proposes block-level warming --> EIP-2930 : Pre-warming with Access Lists +-> EIP-2930 : Pre-warming with Access Lists ( cold and warm access) + - An Ethereum access list transaction enables saving gas on cross-contract calls by declaring in advance which contract and storage slots will be accessed. Up to 100 gas can be saved per accessed storage slot + - Making a cross contract call normally incurs an additional 2600 gas, but using an access list transaction costs 2400 and prewarms the contract access so that it only charges 100 gas, meaning the net cost goes from 2600 to 2500. -> EIP-1822 : Universal Upgradeable Proxy Standard (UUPS) \ No newline at end of file diff --git a/Ethereum/Ethereum.txt b/Ethereum/Ethereum.txt index 93d76e1..faebccb 100644 --- a/Ethereum/Ethereum.txt +++ b/Ethereum/Ethereum.txt @@ -50,7 +50,7 @@ Pruned nodes (like archive nodes vs. full nodes) may discard older logs to save space. -> user case and problem : we have created a smart contract wallet with social recovery and we have initialized smart contract account in both ethereum and zksync and you have lost your EOA which you used to initialize the smart contract accounts - and some one sent you mony on optimism and you can't initialize the smart contract account with same address in optimism because + and some one sent you money on optimism and you can't initialize the smart contract account with same address in optimism because you have used create2 and lost EOA adddress to initialize and generate the address of smart contract account -> Why Gas Exist in the first place : Ethereum is a Turing-complete system. Turing-complete systems face the challenge of the halting problem i.e. given an arbitrary program and its input, it is not solvable to determine whether the @@ -71,7 +71,7 @@ -> scurge -> selfdestruct will let you kill the contract even if the conctract has arbitrary large numner of storage slots - this means there is not upper bound on the amount of state within in that could change within in a single block - - if in contract has a million object and if we selfdestruct this contract then this million objects will go away ( handling this edge case is complex and for this we need to add large amount of extra code on the client developers) + - if a contract has a million object and if we selfdestruct this contract then this million objects will go away ( handling this edge case is complex and for this we need to add large amount of extra code on the client developers) - hardlimit on number of the storage slots that can change within in a single block -> Turing machine - https://grok.com/share/bGVnYWN5_c9eaca24-3cb6-4863-8577-ecded478336f - A Turing machine can perform any computation that can be described by an algorithm, given enough time and resources @@ -81,4 +81,5 @@ Balance: The amount of ETH the account holds. Storage Hash: A Merkle root representing the account's storage. Code Hash: A hash of the account's associated code (empty for EOAs). --> shamir backup - social recovery wallet \ No newline at end of file +-> shamir backup - social recovery wallet +-> An SRP ( Seed Recovery Phrase ) restores the entire wallet with all its derived accounts, while a Private Key only restores one specific account. \ No newline at end of file diff --git a/Ethereum/Solidity.txt b/Ethereum/Solidity.txt index 8c4ca3a..7b2e26a 100644 --- a/Ethereum/Solidity.txt +++ b/Ethereum/Solidity.txt @@ -339,7 +339,7 @@ -> Function name match checking from the call data of the transaction - Each selector == X comparison (and the associated branch, JUMPI) has a constant gas cost—approximately 22 gas for the comparison plus the jump logic -> As you can imagine, this is because different op-codes are needed for each one of this different functions (which all achieve the exact same result) - - num += 1 ; (26429 gas) num = num +1 (26416 gas) num++ (26368 gas) ++num (26362 gas) + - num += 1 ; (26429 gas) , num = num +1 (26416 gas) , num++ (26368 gas) , ++num (26362 gas) -> Memory expansion cost - When a contract call needs to use more than 32 kilobytes of memory storage in a single transaction, the memory cost will enter into a quadratic section - compare 1,000 , 10,000 and 20,000 arrays with sizes diff --git a/Ethereum/noir.txt b/Ethereum/noir.txt index 599317a..dd87ecd 100644 --- a/Ethereum/noir.txt +++ b/Ethereum/noir.txt @@ -1 +1,16 @@ --> In Noir (just like in Rust), the presence or absence of a trailing semicolon turns an expression into either a value‑producing expression (no semicolon) or a statement that returns () (with a semicolon) \ No newline at end of file +-> In Noir (just like in Rust), the presence or absence of a trailing semicolon turns an expression into either a value‑producing expression (no semicolon) or a statement that returns () (with a semicolon) +-> Field :: It is an integer type whose maximum value is determined by the field modulus of the underlying proving system. +-> How are test functions identified and utilized in the Noir programming language? - By using the `#[test]` attribute above a function definition, to verify circuit logic with specific inputs. +-> In cryptographic systems that utilize proofs of computation, what is the fundamental role of a 'verification key'? - It allows an entity to validate a submitted proof for a specific computation without needing access to the secret inputs or the full circuit. +-> Arrays must be statically sized, meaning their length is known at compile time. + + + + + + + + + + + diff --git a/Ethereum/speedDev/speedDev.txt b/Ethereum/speedDev/speedDev.txt index b511eb7..2c3b765 100644 --- a/Ethereum/speedDev/speedDev.txt +++ b/Ethereum/speedDev/speedDev.txt @@ -5,11 +5,12 @@ - HEAD~2 = two commits before, etc. - git revert -> command + w - to close the current working file in vs code --> ctrl + backtick(`) - to toggle the terminal in vscode +-> Ctrl+J = Jump down (to the bottom panel). - VS code terminal -> Minimize Current Window - ⌘ Command + M -> Maximize / Restore (Zoom) Current Window - Control + ⌘ Command + F -> Install baxh-completion for many auto completion features in bash -> clear local storage :: Bookmarklet (One-click outside DevTools) ::> javascript:localStorage.clear();console.log('✅ localStorage cleared'); - Use Bookmark Mnemonics for Speed - just hit Cmd + L, type cl, and press Enter -> Cmd + L - to focus the address bar , then hit tab repeatedly to until it focus on the bookmarks --> Cmd + tab - to shift to new opened apps \ No newline at end of file +-> Cmd + tab - to shift to new opened apps +-> Capture Chrome Screenshot without other tabs , bookmarks and extentions :: In Chrome : cmd + opt + i and then cmd + shift + p and then search for capture screenshot diff --git a/Ethereum/wagmi.txt b/Ethereum/wagmi.txt new file mode 100644 index 0000000..237be15 --- /dev/null +++ b/Ethereum/wagmi.txt @@ -0,0 +1 @@ +--> npx create-next-app@latest -e https://github.com/Seth-McKilla/nextjs-wagmi \ No newline at end of file diff --git a/Ethereum/web3_stack.txt b/Ethereum/web3_fullstack.txt similarity index 93% rename from Ethereum/web3_stack.txt rename to Ethereum/web3_fullstack.txt index ba68270..e1d563e 100644 --- a/Ethereum/web3_stack.txt +++ b/Ethereum/web3_fullstack.txt @@ -26,6 +26,7 @@ Example projects -------------------------------------- BACKEND ------------------------------------------------- -> Indexing - rindexer ( uses postgress db) - building database, indexes, exposing GraphQL APIs - ( Alternatives , The graph protocol ) + - Docker Compose is a tool for running and managing multi-container Docker applications using a simple YAML file (docker-compose.yml) - graphql diff --git a/Ethereum/zksyncOrlayer2OrRollup.txt b/Ethereum/zksyncOrlayer2OrRollup.txt index f579a2a..2c4b151 100644 --- a/Ethereum/zksyncOrlayer2OrRollup.txt +++ b/Ethereum/zksyncOrlayer2OrRollup.txt @@ -138,13 +138,15 @@ -> When an integer is defined in Noir without a specific type, it will default to Field. The one exception is for loop indices which default to u32 since comparisons on Fields are not possible -> nargo execute :: it will compile the circuit into ACIR and it will execute our compiled circuits using the provided inputs in the Prover.toml and then compute a witness and then we will use this witness to create proof --> creating Proof :: nargo prove -b -w -o +-> creating Proof :: bb prove -b -w -o -> Verification key :: is basically a cryptographic object that allows the verifier to check the validity of the proof without having to rerun the full computation - if we change something in the circuit we again need to regenerate the proof and the verification key - kind of digital finger print for the circuit - bb write_vk -b -o - verifier would be creating this verification key from the byte code and then using it to verify the proof - bb verify -k -p +-> In the context of developing Zero-Knowledge proofs with Noir, what does a 'Witness' represent? + - A complete set of all intermediate values and assignments that satisfy the circuit's constraints for a specific input -> In General signature is of 65 bytes - ( r is of 32 bytes , s is of 32 bytes , v is of 1 byte ) -> To execute a shell script first we need to convert it to executable - chmod +x script.sh ( change mode executable) -> To generate VK for onchain :: bb write_vk --oracle_hash keccak -b -o @@ -227,7 +229,7 @@ -> Cartesian Merkle Tree (CMT) is an elegant synergy of three data structures: the binary search tree, the heap, and the Merkle tree - The CMT nodes store three values: the key, the priority, and the merkleHash - https://medium.com/distributed-lab/cartesian-merkle-tree-the-new-breed-a30b005ecf27 --> +-> What is the primary purpose of a library (`"lib"`) crate in Noir? - To create reusable Noir code that can be shared across different projects. ------------------------------------------------------------------------------------------------------------------------------ diff --git a/Foundry_fundamentals.txt b/Foundry_fundamentals.txt index bd196a7..cc516bd 100644 --- a/Foundry_fundamentals.txt +++ b/Foundry_fundamentals.txt @@ -5,6 +5,7 @@ --> (storing private key) cast wallet import one_anvil --interactive --> cast wallet public-key --account one_anvil --> cast wallet sign --no-hash --account one_anvil +--> cast keccak "hello" --> cast send 0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9 "store(uint256)" 345 --account one_anvilca --> foundryup , foundryup-zksync --> forge fmt @@ -74,4 +75,8 @@ --> To see the logs in the js file when we run vm.ffi bytes memory result = vm.ffi(cmds); string memory output = string(result); - console.log("Script Output: %s", output); \ No newline at end of file + console.log("Script Output: %s", output); +--> Foreign Function Interface (FFI) - To run arbitary cli scripts +--> So Chisel is just showing you for : abi.encode("name") - output will be ( pointer + length + actual data) + Memory layout (how EVM stores it) + Tuple encoding layout (how ABI would serialize it for function calls / logs) \ No newline at end of file diff --git a/Questions.txt b/Questions.txt index faf9f37..bafd7fa 100644 --- a/Questions.txt +++ b/Questions.txt @@ -47,6 +47,7 @@ Need to check when destructing from a direct struct and a function returning a s -> what is eip 4844 proto dank sharding ? -> How single slot finality works under the hood -> what is two party computation , fully homomorphic encryption and proof of person hood protocols +-> How flashbots prevents the MEV like attacks # https://www.vigilseek.com/ diff --git a/Rust/rust.txt b/Rust/rust.txt deleted file mode 100644 index 43402dc..0000000 --- a/Rust/rust.txt +++ /dev/null @@ -1,10 +0,0 @@ --> Rust is a systems programming languge that is fast and efficient, and it is also memory safe. It is a statically - typed language, which means that the type of a variable is known at compile time. --> Default variable type will be i32 --> bool , char , i32 , i128 , f64 --> dynamic variable data will be store in heap , where as the memory address of that variable will be stored in stack --> Dangling Pointer - two memory addresses are pointing to the same location in the heap --> borrowing will not have ownership nor it wont copy the data to heap --> In Rust, &str and String both represent text, but they have important differences in ownership, mutability, and memory allocation --> Collections - vec , hashmap , hashset , vecdeque , linkedlist ( double linkedlist ) --> You can use impl to define methods for a struct \ No newline at end of file diff --git a/Rust/rust_cyfrin.txt b/Rust/rust_cyfrin.txt new file mode 100644 index 0000000..bf68ba3 --- /dev/null +++ b/Rust/rust_cyfrin.txt @@ -0,0 +1,133 @@ +Resource :: https://github.com/18121A05L2/rust-crash-course + +-> Functions that end with an exclamation mark are called macros in Rust. They are used to define custom code that can be reused across the project. +-> Type annotations for all function parameters are mandatory in Rust. +-> use scalar::*; + - use = bring names into scope. + - scalar = a module (a file, or a mod scalar { ... } block, or a dependency crate). + - * = glob import (means “everything that's public inside scalar). +-> we have overflow / underflow issues in rust + - in general overflow/underflow panics, but doesn't panic when compiled with --release + - x.wrapping_add(y) - Always wraps (like release mode) + - x.checked_add(y) - Returns Option (None on overflow) + - x.saturating_add(y) - Clamps to max/min value + - x.overflowing_add(y) - Returns a tuple (value, did_overflow) +-> What characteristic primarily defines the size (in bits) of the `usize` and `isize` integer types in Rust? + - The pointer size of the target system's architecture (e.g., 32-bit or 64-bit). +-> char in Rust is always 4 bytes and can represent any Unicode scalar value. +-> Slicing an array let s = &nums[3..7]; - Why do we need & in &nums[3..7] + - So you must borrow it with & to get a slice reference (&[i32], &str, etc) +-> In Rust, what is the primary role of a slice type like `&[i32]`? + - To provide a borrowed, dynamically-sized view into a contiguous sequence of elements (like an array or part of a `Vec`). +-> String interpolation - format! +-> &str - string slice , string literal +-> #![...] means the attribute applies to the whole crate/module. + #[...] (single #) means it applies to the next item only. +-> enum (enumeration) - To define a custom data type by listing all its possible distinct values, known as variants. + - Option = Some(T) | None [value might or might not be there.] + - it designed to handle situations where a value might be absent, thereby helping to prevent null reference errors + - Result = Ok(T) | Error(E) [operation might succeed or fail.] +-> A vector is just like an array except that it can grow or shrink in size. +-> Some(1).as_ref() converts Option into Option<&u32> + - i.e. Some(1) → Some(&1). +-> Rust does not allow "null" values like other languages (Java, C#, etc.) because they cause runtime errors (NullPointerException). + - Instead, Option forces you to handle the case where the value may not exist +-> You need to use * whenever you want to directly read or write the value behind a reference + - helpful when updating hashmap values + - Deref Coercion (Auto Dereferencing) - &String is automatically deref'd to &str +-> std::any::type_name_of_val(&x) - To know the type of a datatype +-> the type for the length for arrays and vecors are usize +-> if a `loop` is used as an expression (e.g., assigned to a variable), how is a value typically returned from it + - By providing the value after the `break` keyword (e.g., `break my_value;`). +-> Which scenario is most suitable for using an `if let` expression in Rust? + - When you need to execute code for only one specific variant of an enum and ignore the rest. +-> stack + - stores data of fixed size known at compile time + - data accessibility and storing data is fast + - follow LIFO + - Example Datatypes :: u32 , i32 + heap + - stored data of unknown size at compile time + - slower than stack + - memory safety is enforced through Rust's ownership and borrowing rules + - Example DataTypes :: strings and vectors + - let boxed = Box::new(20i32) - to store stack data specifically on heap +-> Box::new creates a smart pointer that allocates a value on the heap, and gives you ownership of that heap allocation +-> for copy trade data types - ownership wont be transfered by assigning like the case for String::from("hello") + - Data types that implements Copy trait - Primitive, fixed-size, simple value types (stored entirely on the stack, no heap allocation): + - Compound types (if all members are Copy): + - Tuples, e.g. (i32, bool) is Copy (because both i32 and bool are Copy) + - Which types do NOT implement Copy - Types that own heap memory or manage resources cannot be copied by just bitwise duplication. They must move instead. +-> unwrap and expect are the two functions that you can call to get the inner values of a Option or Result + - Returns the inner value if it exists (Some or Ok). + - Panics (crashes the program) if it's None or Err. + - with expect we can have a custom error message +-> The main purpose of the ? (question mark) operator in Rust is to make error handling with Result (or Option) more concise + - the ? operator can only be used in a function that returns Result or Option + - where we can use this ? - if any expression is an error or None, stop here and return that error/None from the current function. +-> cargo test -- --nocapture ( To see logs when the the test ran successfully ) +-> Modules are the way to oraganize code in Rust +-> Super - means go one module level above and check for the module +-> a generic type is a type parameter that allows you to write flexible, reusable code that works with multiple data types without duplicating logic +-> Functions that operate on a type are called static methods also known as associated functions + - They're usually used as constructors (new) or utility functions +-> the functions that operate on an instance of the type are called methods + - A method takes self, &self, or &mut self as its first parameter +-> monomorphization is the process the compiler uses to turn generic code into specific, concrete code for each type that's actually used + - Advantages of monomorphization + - Zero cost abstraction: generic code runs just as fast as handwritten code for a specific type. + - Type-safety is preserved, since each instantiation is strongly typed. + - Downsides + - Code bloat: if you use a generic with many different types, the compiler generates multiple copies → larger binaries. + - Longer compile times, since the compiler has to generate and optimize multiple versions. +-> Trait - A trait in Rust is a collection of methods that a type can implement, letting you write generic, reusable, polymorphic code + - A common interface for a group of types. + - A trait is like an interface that data types can implement. When a type implements a trait it can be treated abstractly as that trait using generics or trait objects + - It defines a set of methods that a type must implement if it wants to “have that trait.” +-> Trait bound is a way to tell the rust compiler that a type(T) implements a trait. This becomes necessary when you work with generic functions + - vectors in Rust don't allow moving elements out by index + - That would leave a "hole" in the vector. + - Only Copy types (like integers) can be implicitly copied like this +-> A lifetime in Rust is the scope during which a reference (&T) is valid + - this is to prevent dangling references + - A reference that points to a memory location that has been deallocated or is no longer valid. + - we only define lifetimes - When the compiler cannot infer the relationship between the lifetimes of input references and a returned reference. + - Lifetimes are required when your data type holds references + - What does the special lifetime `'static` indicate when applied to a reference in Rust + - The reference points to data that is valid for the entire duration of the program. + - Since Rust avoids garbage collection, it must ensure that: References never outlive the data they point to. + - fn longest<'a>(...) -> ... + - Here you introduce a lifetime parameter 'a. + - Think of 'a as a placeholder for “some lifetime that will be decided by the caller.” + - s1 and s2 are created inside main. + - They both live until the end of main. + - So, when calling longest(&s1, &s2), the compiler figures out: + - &s1 → lifetime 'a1 (valid until main ends). + - &s2 → lifetime 'a2 (valid until main ends). + - Rust unifies them into a common 'a = min('a1, 'a2). + - Thus, the returned reference is guaranteed to be valid at least until both s1 and s2 are still alive. + - My return value can live only as long as the shorter of my two inputs. + - Ellison rules + - Each input reference gets its own lifetime parameter + - If there is exactly one input reference, that lifetime is assigned to all output references + - If there are multiple input references, but one of them is &self or &mut self, then the lifetime of self is assigned to all output references + - Ellison fail case scenario + - If multiple input references exist and none of them is self, the compiler won't know which lifetime the return value should be tied to: +-> Iterators + - into_iter() : iterate over T ( transfers ownership ) + - iter() : iterate over &T + - iter_mut() : iterate over &mut T +-> Iterator Adaptors :: map , filter and collect + - iterator adapters are the functions that we can call on our iterator + - filter() always passes a reference &Item ( as an argument ) + - map() gives you whatever Item is + - `collect()` is a generic method that can create many different kinds of collections, so the compiler needs the type annotation to know the specific target collection type. +-> Async runtime - An async runtime is a specialized runtime that knows how to drive asynchronous tasks.It's what makes .await actually do something + - Rust's async/await is zero-cost at compile time — it just creates state machines that represent potentially paused tasks. + - But to actually run those tasks, you need an executor — and that executor lives inside the async runtime. + - A reactor: waits for I/O events (like sockets ready to read/write) + - An executor: polls async tasks until they finish + - Optionally: a scheduler: decides which task runs next on which thread +-> join macro - Waits for all of them to complete + select macro - Returns as soon as one of them completes + diff --git a/Rust/rust_microsoft_basics.txt b/Rust/rust_microsoft_basics.txt new file mode 100644 index 0000000..471f53e --- /dev/null +++ b/Rust/rust_microsoft_basics.txt @@ -0,0 +1,99 @@ +Begginers tutorial - https://www.youtube.com/playlist?list=PLlrxD0HtieHjbTjrchBwOVks_sr8EVW1x + examples - https://github.com/microsoft/beginners-series-rust + practise - https://github.com/18121A05L2/rust-crash-course + +-> Rust is a systems programming languge that is fast and efficient, and it is also memory safe. It is a statically + typed language, which means that the type of a variable is known at compile time. + EX : Operating systems , web browsers , databases , webservers , firmware + Firmware is software embedded directly into a hardware device to control its functions, acting as a bridge between the hardware and the operating system + Firmware is store in flash memory + Flash memory is a type of non-volatile computer storage that retains data even when the power is off, utilizing floating-gate transistors to store information electronically +-> Rust is the language used to build the software that powers the underlying systems that other software runs on top of +-> Rust , C , C++ does not require the use of garbage collection +-> Rust provides memory safety gurantees ( below two are not possible in rust , which are hard to debug in c and c++ ) + - user after free + - dangling pointer + - null pointer exceptions + - data races + - iterator invalidation +-> Rust has built in :: integrated build tooling, Package manager , Opensource package repository , default testing framework , Auto generate documentation + - crates.io : official Rust package registry. + - Cargo : package manager and build system +-> cargo is the rust build tool , dependency manager , test runner and project bootstrapper all rolled into one + - cargo new , cargo run , cargo build +-> Variables are immutable by default + - Mutalbe variable example - let mut variableName = value +-> Default variable type will be :: in signed - i32 , in floating points - f64 +-> Scalar DataTypes - bool , char , i32(signed) , u32(unsigned) , f32(floating point) , i128 , f64 + - A char in Rust represents exactly one Unicode scalar value (one character). + - use single quotes for char and use double quotes for string literal +-> Type inference (like with let) is not allowed for const +-> A const in Rust is computed entirely at compile time — no heap allocation, no runtime logic, no non-const function calls. +-> constants can only set to be an expression, not the result of an function call or anything else with the value that is computed at program runtime +-> Static - A single memory location that exists for the entire program (like a global variable). +-> Rust is a compiled systems language, not a scripting language like Python or JavaScript.In Rust, code outside functions runs at compile time, not runtime +-> Compound data types - Arrays , Tuples ( The word compound means “made up of two or more parts.”) +-> Arrays + - fixed length (length known at compile time) + - homogenous type ( only contain items of same type ) + - panics at run time if the index is out of bounds +-> Tuple + - unlike arrays tuples are heterogenous , the only difference betweeen arrays and tuples + - we call the empty tuple as unit +-> function syntax - fun (input : String) -> String {} + - we must need to define the input type and must define return type of we return something + - if we dont return anything , return type is unit which is empty tuple +-> Difference between + - String and &str + - Use &str when: You only need to read a string + - A borrowed view into a string. + - Immutable, you can't change its contents + - a sticky note someone gave you (borrowed view, can't change it) + - &str has one part - pointer to data and length + - Use String when: You need an owned, growable string.You want to store or modify string data. + - More expensive (allocates on heap) + - your own notepad (heap-allocated, you can write/erase freely) + - String has threeparts - pointer to data , length and capacity + - array and tuple +-> "{}" - Display , "{:?}"- Debug , "{:#?}" - pretty debug +-> enums - list all variations of some data +-> loop keyword - Used to execute a block of code forever. Or until it is stopped Or the program quits +-> match - it is kind of switch in other programming languages +-> Structs is of three types - classic , tupple and unit +-> panic! - used to throw an error +-> rust stores data in two differently structures parts of memory ( just like other major programming languages ) + - stack ( LIFO ) + - vector - object stored on stack with pointer to heap + - variable - variable and value is stored on stack + - heap + - value of vecor is stored on heap +-> dynamic variable data will be store in heap , where as the memory address of that variable will be stored in stack +-> Dangling Pointer - two memory addresses are pointing to the same location in the heap + - the pointer on the stack that points towards the heap which is no longer available is known as a dangling pointer ( this is becuase we drop the one of the pointer which leads to data deletion on the heap which is pointing by two memory addresses on the stack) + - in C and C++ this depend on programmer to explicitily manange the memory with their code + - python, ruby and javascript have garbage collector which automatically manage the memory + - the garbage collector is a program that runs when our program runs and it constantly lookup for the memory that is no longer used and cleanup that memory + - rust prevents this with the help of the ownership +-> Rules of ownersip + - Each value in rust has a variable that's called its owner + - There can only be one owner at a time + - When the owner goes out of scope , the value will be dropped + - ownership prevents memory safety issues + - Double free ( trying to free memory that has already been freed ) + - Memory leaks ( Not freeing memory that should have been freed ) +-> Rules of Borrowing ( using &) + - at any given point of time, you can have either : + - One mutable reference or + - Any number of immutable references + - references must always be valid +-> borrowing will not have ownership nor it wont copy the data to heap +-> In Rust, &str and String both represent text, but they have important differences in ownership, mutability, and memory allocation +-> Collections - vec (access by index) , hashmap (associate keys and values) , hashset (unique items and no access by index), vecdeque , linkedlist ( double linkedlist ) + - vec - which is a global continuous stack of items of the same type +-> You can use impl to define methods for a struct + - impl mean implementation block - It's where you implement methods, associated functions, or traits for a type (like a struct, enum, or trait) + - Associated function ( static methods ) - If a function inside impl does not take self, it's an associated function — like a static method in other languages. +-> Clone - Copies data on both heap and stack +-> Borrowing - if we dont want to create a full copy on both the stack and the heap , we can use a technique called borrowing + - borrowing create a reference to the value of that variable +-> &String automatically coerces to &str - Rust allows something called "deref coercion", which is an automatic conversion that happens when you pass a reference of one type to a function expecting a reference of another (related) type diff --git a/frontEnd/office.txt b/frontEnd/office.txt index 4590060..2569350 100644 --- a/frontEnd/office.txt +++ b/frontEnd/office.txt @@ -5,4 +5,5 @@ -> firebase tools -> AWS -> How to use google notebook llm --> create a merkle tree using with all functionalities in js \ No newline at end of file +-> create a merkle tree using with all functionalities in js +-> tanstack query which is used in wagmi \ No newline at end of file diff --git a/ideas.txt b/ideas.txt index 4faede0..6e7c1d1 100644 --- a/ideas.txt +++ b/ideas.txt @@ -6,4 +6,6 @@ -> EMI's on blockchain -> Chrom extentions like sponsor or ad skip for youtube videos -> How about raising an EIP , by wrapping around ERC20 and adding something like tags , so that if someone hacks any ERC20 token we can block those hacked tokens by having each token a unique identifier mapped to the tags - - we can add this one to the base ETH which we pays for gas \ No newline at end of file + - we can add this one to the base ETH which we pays for gas +-> Todays hardware wallet sucks , we need to implement robust and clearly users can see what they are signing +-> why we need to provide liquidity to each individual pool pair , what if we have something like provide liquidiy to a pool where we can trade every asset in that pool ( need a robust formulae for this) \ No newline at end of file diff --git a/immediateTodos.txt b/immediateTodos.txt index 1043cb6..8074539 100644 --- a/immediateTodos.txt +++ b/immediateTodos.txt @@ -1,2 +1,12 @@ +-> complete Raisebox Faucet codehawks tomorrow + +-> need to go throgh all rust concepts and build a small project on solana + +-> try for transaction verification before submitting and go through the safe wallet + + + + +# --------------------------- DONE --------------------- -> need to build zkmixer , by end of july 2025 - will all latest tech stack \ No newline at end of file diff --git a/miscellaneous/terminologyOrMeaningsOrNaming.txt b/miscellaneous/terminologyOrMeaningsOrNaming.txt index 6587d29..85c60a3 100644 --- a/miscellaneous/terminologyOrMeaningsOrNaming.txt +++ b/miscellaneous/terminologyOrMeaningsOrNaming.txt @@ -4,4 +4,5 @@ -> allege - claim or assert that someone has done something illegal or wrong, typically without proof. -> succinct - (especially of something written or spoken) briefly and clearly expressed. (short and fast to check in blockchain terminology) -> Ethereum 2.0, also known as Serenity --> In database terminology, "upsert" means to either update an existing record or insert a new one if the record doesn't already exist \ No newline at end of file +-> In database terminology, "upsert" means to either update an existing record or insert a new one if the record doesn't already exist +-> LGTM - Looks Good to me \ No newline at end of file