开发者
Zero-Latency DeFi: Parsing Raw Solana AMM Accounts in Rust
Originally published on xroot.dev . In high-frequency Web3 infrastructure, relying on a TypeScript SDK or a third-party pricing API means you are already too late. If you are building an arbitrage bot, a sniper, or a real-time indexer on Solana, reading data through abstracted REST endpoints introduces hundreds of milliseconds of latency. To build institutional-grade infrastructure, you have to bypass the middleman. You need to pull the raw binary state of the Automated Market Maker (AMM) directly from the RPC node and deserialize it natively in memory. Here is how to reverse-engineer Solana DeFi pools and parse raw account data in Rust at microsecond speed. The Anatomy of a Solana Account & The Anchor Discriminator Beneath the abstractions of the Solana ecosystem, an account's data is fundamentally just a continuous array of bytes ( &[u8] ). When a smart contract writes to an account, it serializes its state into this raw byte buffer. If the AMM was built using the Anchor framework — which the vast majority of modern Solana DeFi protocols are — the account data doesn't just start with the struct variables. Anchor prepends an 8-byte discriminator to the beginning of the data payload. This discriminator is calculated using the first 8 bytes of the SHA256 hash of the string "account:StructName" . It acts as a safety check: if you try to deserialize an AMM pool account but the first 8 bytes don't match the expected hash, the program knows you passed the wrong account type and immediately aborts. Bytes 0–7 (Anchor Discriminator) → Bytes 8–N (Raw struct data (Borsh-serialized)) To parse the account data yourself, your first step is always identifying and slicing off those first 8 bytes. Reverse-Engineering the AMM Struct You cannot parse binary data without knowing its exact memory layout. We need to map the byte layout of the DeFi pool — such as a Raydium CPMM or a pump.fun bonding curve — into a tightly packed Rust struct . Instead of paying the "Borsh tax" (the CPU ov
开发者
The Stack Nobody Picks Might Be the One That Picks You
Nobody chooses .NET. Not as a student, at least. You hear "backend" and the room splits into Spring...
AI 资讯
My Mac Is Useless for Local AI. My Windows Laptop Isn't.
I own two laptops. A 2020 Intel MacBook Air, 8GB RAM, no unified memory, gifted by my sister. And a...
开发者
Top 7 Featured DEV Posts of the Week
Welcome to this week's Top 7, where the DEV editorial team handpicks their favorite posts from the...
开发者
Crazy Things I've thought about since childhood 🤯
Some random questions that have been living rent-free in my head since I was a kid... So...
AI 资讯
Semantic caching isn't a cost-saving hack. It's an admission that most "AI features" are FAQ bots in disguise.
Intro There's a pitch behind every new AI-powered feature: it understands anything a user...
AI 资讯
Keep Your Heart Rate to Yourself: Building Privacy-First Fitness AI with Federated Learning
In the era of hyper-personalized fitness, data is the new "pre-workout." We want our smartwatches to tell us exactly how many calories we burned, but there’s a massive catch: Privacy . Giving a centralized cloud server access to every heartbeat, GPS coordinate, and sleep cycle feels increasingly like a security nightmare. This is where Federated Learning and Edge AI come to the rescue. Instead of sending your raw data to the cloud, we send the model to your device, train it locally, and only share the encrypted mathematical updates. In this tutorial, we will build a collaborative fitness model using Flower (flwr) and PySyft to predict calorie expenditure across a community of users without a single byte of raw heart rate data ever leaving their phones. Why Decentralized Machine Learning? 🥑 Before we dive into the code, let's look at the "Why." Standard machine learning requires a data lake. Federated Learning (FL) enables Privacy-Preserving AI by keeping data siloed on the edge. This is crucial for HIPAA compliance and building trust in community-driven health apps. The Architecture: Federated Optimization Loop Here is how the data flows in our group fitness ecosystem. Notice that the "Server" only sees weight updates, never the raw heart rate logs. sequenceDiagram participant S as Aggregation Server participant C1 as User A (Edge Device) participant C2 as User B (Edge Device) Note over S: Global Model Initialized S->>C1: Send Initial Model Weights S->>C2: Send Initial Model Weights Note over C1: Train on Local HR Data Note over C2: Train on Local HR Data C1->>S: Send Local Gradient Updates C2->>S: Send Local Gradient Updates Note over S: FedAvg Algorithm (Aggregating Weights) S->>C1: Send Updated Global Model S->>C2: Send Updated Global Model Prerequisites 🛠️ To follow this advanced guide, you'll need: Python 3.9+ Flower (flwr) : For federated orchestration. NumPy : For local data processing. PySyft : For differential privacy concepts. pip install flwr numpy Step 1
AI 资讯
Mercury rejected you. Here is the math behind it, and what to do next
The email arrives. "Mercury will not be able to support your business at this time. We will not be able to provide additional details about this decision." You spend the next two weeks building an appeal: residence permit, business plan, tax registration, customer contracts, the whole file. You attach a polite cover letter explaining that you are not in Russia, not a sanctioned individual, fully compliant. Mercury either does not respond or sends the same boilerplate back. By week three you have decided you did something wrong, that your business is somehow tainted, that you will never get a US bank account. None of that is true. The reject was a system response, and once you can see the arithmetic driving it, the next move gets obvious and the spiral stops. The math behind an auto-decline OFAC violation penalties start at roughly $1 million per transaction. The annual revenue from a single diaspora-founder account at Mercury sits somewhere between $50 and $500. On top of that sits reputational risk: one Bloomberg story about "the fintech serving sanctioned Russians" damages the next funding round, strains banking partner relationships, and invites regulatory attention. Run those numbers and an auto-decline on an RU or BY passport signal becomes the rational move for the fintech, even when the overwhelming majority of flagged applications are perfectly legal. The downside of a single miss outweighs the upside of correctly clearing every legal applicant. What you are looking at is a company optimising against an asymmetry: maximum downside, minimal upside, per application. There is no judgement of you anywhere in that calculation. How the decline actually happens A KYC submission includes a passport scan, residence permit, and business documents. The decisioning system flags an RU or BY passport regardless of where you live, how the company is structured, or where the revenue comes from. Human review exists, but it triggers only when the signal-to-noise ratio is exce
AI 资讯
I Can’t Read Music, But AI in Music Made Me Feel Like a Producer
Have you ever had a melody, lyric, or song idea stuck in your head but felt completely unqualified to...
AI 资讯
FTC lawsuit alleges Amazon has been ‘secretly and systematically’ overcharging for ads
The FTC and 22 state attorneys general are suing Amazon for allegedly using a "secret ad surcharge" to drive up prices for ads on its website and app. FTC chairman Andrew Ferguson claims in a blog post on the lawsuit that the higher advertising prices "were largely passed on to American consumers." According to the […]
科技前沿
Trump admin shelves Cyclospora research despite record-breaking outbreak
The CDC has tallied nearly 30,000 confirmed and probable cases this summer.
AI 资讯
“Zlibrary my beloved”: Anthropic staff chats extolling piracy cited in Sony suit
Lawsuit: Anthropic’s torrenting totally screwed songwriters as AI songs top charts.
AI 资讯
Car owners want tech they can ignore
Automakers keep shoving more tech into their cars, despite evidence that consumers are increasingly fed up with huge screens and glitchy software. In fact, the features that car owners appreciate the most happen to be the ones they barely notice, according to the latest tech survey from JD Power. The consumer research firm surveyed 68,084 […]
AI 资讯
Tim Cook’s parting message: Apple is in the hands of a product builder
Tim Cook’s farewell memo to Apple employees offers a glimpse at how he wants John Ternus to be seen: as a product builder with deep experience across the iPhone, Mac, AirPods, and other major hardware lines.
AI 资讯
The start of a new journey
Have you ever wondered why we keep learning advanced things that probably might not be applied properly where we came from? As someone who came from a developing country where resources are not being served on a gold plate. In fact, even if you have all the necessary knowledge to make a change but one thing comes up with no answer, how can we implement our knowledge gained abroad with no funding and no equipment to help us contribute to the blooming of our beloved country? I guess our parents worked hard to actually send us abroad, not to return to our country but instead to find a way to make a living where God destined us to go. This is not because they hate our homeland, but they feel there is no way things can change where corruption and unemployment reign to a high degree. Therefore, this is the time where advanced technologies must not be seen as burdens in a developing country. Share answers on this particular spec. Thanks!
开发者
George Santos Just Got Hit With Kalshi’s First-Ever Lifetime Ban
The former US representative was also fined more than $71,000 for allegedly attempting to manipulate the prediction market.
AI 资讯
n8n 'No testing function found for this credential' Fix
What actually changed You built a custom n8n node with its own credential type. The node works in a workflow. You open the credential in the n8n UI, click Test , and instead of a green checkmark you get: No testing function found for this credential. You double-check the node — credentialTest is defined in methods , testedBy is set on the credential declaration, everything compiles. n8n just refuses to see it. This is one of the most-reported custom-node issues in n8n's history — the original report is Stack Overflow q/75109822 and the underlying bug is tracked in n8n-io/n8n#8188 , with users still reproducing it on 1.58+ and 1.94 well after the original fix landed. The fix The root cause is not a missing function. It is in LoadNodesAndCredentials.ts : n8n generates nodesToTestWith in dist/known/credentials.json but only reads supportedNodes when linking a credential to its test function. For custom and community nodes the two keys never match, so the linkage is dropped and the UI shows the "no testing function" message. The fix that survives across n8n versions is to stop relying on credentialTest on the node and instead define the test directly on the credential class as an ICredentialTestRequest . Before — the linkage that breaks // credentials/MyApi.credentials.ts import { ICredentialType , INodeProperties } from ' n8n-workflow ' ; export class MyApi implements ICredentialType { name = ' myApi ' ; displayName = ' My API ' ; // ❌ testedBy points at the node's credentialTest, which the loader // never resolves for custom/community nodes. testedBy = ' MyApiNode ' ; properties : INodeProperties [] = [ { displayName : ' API Key ' , name : ' apiKey ' , type : ' string ' , typeOptions : { password : true }, default : '' , }, ]; } // nodes/MyApi.node.ts export class MyApiNode implements INodeType { methods : INodeTypeMethods = { credentialTest : async ( credentials ) => { // n8n never calls this for a custom node. const res = await fetch ( ' https://api.example.com/me '
开源项目
🔥 alphaXiv / openresearch-cli - Run parallel research agents with any model
GitHub热门项目 | Run parallel research agents with any model | Stars: 531 | 65 stars today | 语言: Rust
AI 资讯
You Know Who Really Hates AI? Insurance Claims Adjusters
Of the Glassdoor reviews from claims adjusters that mentioned AI, a staggering 98 percent were negative. “AI is just a tool,” one person tells WIRED. “It should never be given the keys.”
开发者
Best Design Apps I Would Give My Younger Self Starting in Design
If I could go back to my first year in design, I would spend far less time asking "Which design app...