Luke Parker
3f0f4d520d
Remove the Sandbox contract
...
If instead of intaking calls, we intake code, we can deploy a fresh contract
which makes arbitrary calls *without* attempting to build our abstraction
layer over the concept.
This should have the same gas costs, as we still have one contract deployment.
The new contract only has a constructor, so it should have no actual code and
beat the Sandbox in that regard? We do have to call into ourselves to meter the
gas, yet we already had to call into the deployed Sandbox to achieve that.
Also re-defines the OutInstruction to include tokens, implements
OutInstruction-specified gas amounts, bumps the Solidity version, and other
such misc changes.
2024-09-19 23:36:32 -07:00
Luke Parker
80ca2b780a
Add tests for the premise of the Schnorr contract to the Schnorr crate
2024-09-19 23:36:32 -07:00
Luke Parker
1c5bc2259e
Dedicated crate for the Schnorr contract
2024-09-19 23:36:32 -07:00
Luke Parker
bdf89f5350
Add dedicated crate for building Solidity contracts
2024-09-19 23:36:32 -07:00
Luke Parker
239127aae5
Add crate for the Ethereum contracts
2024-09-19 23:36:32 -07:00
Luke Parker
d9543bee40
Move ethereum-serai under the processor
...
It isn't generally usable and should be directly integrated at this point.
2024-09-19 23:36:32 -07:00
Luke Parker
8746b54a43
Don't use a different address for DAI in test
...
anvil will let us deploy to the existing address.
2024-09-19 23:36:32 -07:00
Luke Parker
7761798a78
Outline the Ethereum processor
...
This was only half-finished to begin with, unfortunately...
2024-09-19 23:36:32 -07:00
Luke Parker
72a18bf8bb
Smart Contract Scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
0616085109
Monero Planner
...
Finishes the Monero processor.
2024-09-19 23:36:32 -07:00
Luke Parker
a2d9aeaed7
Stub out Scheduler in the Monero processor
2024-09-19 23:36:32 -07:00
Luke Parker
e1ad897f7e
Allow scheduler's creation of transactions to be async and error
...
I don't love this, but it's the only way to select decoys without using a local
database. While the prior commit added such a databse, the performance of it
presumably wasn't viable, and while TODOs marked the needed improvements, it
was still messy with an immense scope re: any auditing.
The relevant scheduler functions now take `&self` (intentional, as all
mutations should be via the `&mut impl DbTxn` passed). The calls to `&self` are
expected to be completely deterministic (as usual).
2024-09-19 23:36:32 -07:00
Luke Parker
2edc2f3612
Add a database of all Monero outs into the processor
...
Enables synchronous transaction creation (which requires synchronous decoy
selection).
2024-09-19 23:36:32 -07:00
Luke Parker
e56af7fc51
Monero time_for_block, dust
2024-09-19 23:36:32 -07:00
Luke Parker
947e1067d9
Monero Processor scan, check_for_eventuality_resolutions
2024-09-19 23:36:32 -07:00
Luke Parker
b4e94f3d51
cargo fmt signers/scanner
2024-09-19 23:36:32 -07:00
Luke Parker
1b39138472
Define subaddress indexes to use
...
(1, 0) is the external address. (2, *) are the internal addresses.
2024-09-19 23:36:32 -07:00
Luke Parker
e78236276a
Remove async-trait from processor/
...
Part of https://github.com/serai-dex/issues/607 .
2024-09-19 23:36:32 -07:00
Luke Parker
2c4c33e632
Misc continuances on the Monero processor
2024-09-19 23:36:32 -07:00
Luke Parker
f2cf03cedf
Monero processor primitives
2024-09-19 23:36:32 -07:00
Luke Parker
0d4c8cf032
Use a local DB channel for sending to the message-queue
...
The provided message-queue queue functions runs unti it succeeds. This means
sending to the message-queue will no longer potentially block for arbitrary
amount of times as sending messages is just writing them to a DB.
2024-09-19 23:36:32 -07:00
Luke Parker
b6811f9015
serai-processor-bin
...
Moves the coordinator loop out of serai-bitcoin-processor, completing it.
Fixes a potential race condition in the message-queue regarding multiple
sockets sending messages at once.
2024-09-19 23:36:32 -07:00
Luke Parker
fcd5fb85df
Add binary search to find the block to start scanning from
2024-09-19 23:36:32 -07:00
Luke Parker
3ac0265f07
Add section documenting the safety of txindex upon reorganizations
2024-09-19 23:36:32 -07:00
Luke Parker
9b8c8f8231
Misc tidying of serai-db calls
2024-09-19 23:36:32 -07:00
Luke Parker
59fa49f750
Continue filling out main loop
...
Adds generics to the db_channel macro, fixes the bug where it needed at least
one key.
2024-09-19 23:36:32 -07:00
Luke Parker
723f529659
Note better message structure in messages
2024-09-19 23:36:32 -07:00
Luke Parker
73af09effb
Add note to signers on reducing disk IO
2024-09-19 23:36:32 -07:00
Luke Parker
4054e44471
Start on the new processor main loop
2024-09-19 23:36:32 -07:00
Luke Parker
a8159e9070
Bitcoin Key Gen
2024-09-19 23:36:32 -07:00
Luke Parker
b61ba9d1bb
Adjust Bitcoin processor layout
2024-09-19 23:36:32 -07:00
Luke Parker
776cbbb9a4
Misc changes in response to prior two commits
2024-09-19 23:36:32 -07:00
Luke Parker
76a3f3ec4b
Add an anyone-can-pay output to every Bitcoin transaction
...
Resolves #284 .
2024-09-19 23:36:32 -07:00
Luke Parker
93c7d06684
Implement presumed_origin
...
Before we yield a block for scanning, we save all of the contained script
public keys. Then, when we want the address credited for creating an output,
we read the script public key of the spent output from the database.
Fixes #559 .
2024-09-19 23:36:32 -07:00
Luke Parker
4cb838e248
Bitcoin processor lib.rs -> main.rs
2024-09-19 23:36:32 -07:00
Luke Parker
c988b7cdb0
Bitcoin TransactionPublisher
2024-09-19 23:36:32 -07:00
Luke Parker
017aab2258
Satisfy Scheduler for Bitcoin
2024-09-19 23:36:32 -07:00
Luke Parker
ba3a6f9e91
Bitcoin ScannerFeed
2024-09-19 23:36:32 -07:00
Luke Parker
e36b671f37
Remove bound that WINDOW_LENGTH < CONFIRMATIONS
...
It's unnecessary and not valuable.
2024-09-19 23:36:32 -07:00
Luke Parker
2d4b775b6e
Add bitcoin Block trait impl
2024-09-19 23:36:32 -07:00
Luke Parker
247cc8f0cc
Bitcoin Output/Transaction definitions
2024-09-19 23:36:32 -07:00
Luke Parker
0ccf71df1e
Remove old signer impls
2024-09-19 23:36:32 -07:00
Luke Parker
8aba71b9c4
Add CosignerTask to signers, completing it
2024-09-19 23:36:32 -07:00
Luke Parker
46c12c0e66
SlashReport signing and signature publication
2024-09-19 23:36:32 -07:00
Luke Parker
3cc7b49492
Strongly type SlashReport, populate cosign/slash report tasks with work
2024-09-19 23:36:32 -07:00
Luke Parker
0078858c1c
Tidy messages, publish all Batches to the coordinator
...
Prior, we published SignedBatches, yet Batches are necessary for auditing
purposes.
2024-09-19 23:36:32 -07:00
Luke Parker
a3cb514400
Have the coordinator task publish Batches
2024-09-19 23:36:32 -07:00
Luke Parker
ed0221d804
Add BatchSignerTask
...
Uses a wrapper around AlgorithmMachine Schnorrkel to let the message be &[].
2024-09-19 23:36:32 -07:00
Luke Parker
4152bcacb2
Replace scanner's BatchPublisher with a pair of DB channels
2024-09-19 23:36:32 -07:00
Luke Parker
f07ec7bee0
Route the coordinator, fix race conditions in the signers library
2024-09-19 23:36:32 -07:00
Luke Parker
7484eadbbb
Expand task management
...
These extensions are necessary for the signers task management.
2024-09-19 23:36:32 -07:00
Luke Parker
59ff944152
Work on the higher-level signers API
2024-09-19 23:36:32 -07:00
Luke Parker
8f848b1abc
Tidy transaction signing task
2024-09-19 23:36:32 -07:00
Luke Parker
100c80be9f
Finish transaction signing task with TX rebroadcast code
2024-09-19 23:36:32 -07:00
Luke Parker
a353f9e2da
Further work on transaction signing
2024-09-19 23:36:32 -07:00
Luke Parker
b62fc3a1fa
Minor work on the transaction signing task
2024-09-19 23:36:32 -07:00
Luke Parker
8380653855
Add empty serai-processor-signers library
...
This will replace the signers still in the monolithic Processor binary.
2024-09-19 23:36:32 -07:00
Luke Parker
b50b889918
Split processor into bitcoin-processor, ethereum-processor, monero-processor
2024-09-19 23:36:32 -07:00
Luke Parker
d570c1d277
Move additional_key.rs to serai-processor-view-keys
...
I don't love this. I wanted to simply add this function to `processor/key-gen`,
but then anyone who wants a view key needs to pull in Bulletproofs which is a
mess of code. They'd also be subject to an AGPL licensed library.
This is so small it should be a primitive elsewhere, yet there is no primitives
library eligible. Maybe serai-client since that has the code to make
transactions to Serai (and will have this as a dependency)? Except then the
processor has to import serai-client when this rewrite removed it as a
dependency.
2024-09-19 23:36:32 -07:00
Luke Parker
2da24506a2
Remove vast swaths of legacy code in the processor
2024-09-19 23:36:32 -07:00
Luke Parker
6e9cb74022
Add non-transaction-chaining scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
0c1aec29bb
Finish routing output flushing
...
Completes the transaction-chaining scheduler.
2024-09-19 23:36:32 -07:00
Luke Parker
653ead1e8c
Finish the tree logic in the transaction-chaining scheduler
...
Also completes the DB functions, makes Scheduler never instantiated, and
ensures tree roots have change outputs.
2024-09-19 23:36:32 -07:00
Luke Parker
8ff019265f
Near-complete version of the tree algorithm in the transaction-chaining scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
0601d47789
Work on the tree logic in the transaction-chaining scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
ebef38d93b
Ensure the transaction-chaining scheduler doesn't accumulate the same output multiple times
2024-09-19 23:36:32 -07:00
Luke Parker
75b4707002
Add input aggregation in the transaction-chaining scheduler
...
Also handles some other misc in it.
2024-09-19 23:36:32 -07:00
Luke Parker
3c787e005f
Fix bug in the scanner regarding forwarded output amounts
...
We'd report the amount originally received, minus 2x the cost to aggregate,
regardless the amount successfully forwarded. We should've reduced to the
amount successfully forwarded, if it was smaller, in case the cost to
forward exceeded the aggregation cost.
2024-09-19 23:36:32 -07:00
Luke Parker
f11a6b4ff1
Better document the forwarded output flow
2024-09-19 23:36:32 -07:00
Luke Parker
fadc88d2ad
Add scheduler-primitives
...
The main benefit is whatever scheduler is in use, we now have a single API to
receive TXs to sign (which is of value to the TX signer crate we'll inevitably
build).
2024-09-19 23:36:32 -07:00
Luke Parker
c88ebe985e
Outline of the transaction-chaining scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
6deb60513c
Expand primitives/scanner with niceties needed for the scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
bd277e7032
Add processor/scheduler/utxo/primitives
...
Includes the necessary signing functions and the fee amortization logic.
Moves transaction-chaining to utxo/transaction-chaining.
2024-09-19 23:36:32 -07:00
Luke Parker
fc765bb9e0
Add crate for the transaction-chaining Scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
13b74195f7
Don't have acknowledge_batch
immediately run
...
`acknowledge_batch` can only be run if we know what the Batch should be. If we
don't know what the Batch should be, we have to block until we do.
Specifically, we need the block number associated with the Batch.
Instead of blocking over the Scanner API, the Scanner API now solely queues
actions. A new task intakes those actions once we can. This ensures we can
intake the entire Substrate chain, even if our daemon for the external network
is stalled at its genesis block.
All of this for the block number alone seems ridiculous. To go from the block
hash in the Batch to the block number without this task, we'd at least need the
index task to be up to date (still requiring blocking or an API returning
ephemeral errors).
2024-09-19 23:36:32 -07:00
Luke Parker
f21838e0d5
Replace acknowledge_block with acknowledge_batch
2024-09-19 23:36:32 -07:00
Luke Parker
76cbe6cf1e
Have acknowledge_block take in the results of the InInstructions executed
...
If any failed, the scanner now creates a Burn for the return.
2024-09-19 23:36:32 -07:00
Luke Parker
5999f5d65a
Route the DB w.r.t. forwarded outputs' information
2024-09-19 23:36:32 -07:00
Luke Parker
d429a0bae6
Remove unused ID -> number lookup
2024-09-19 23:36:32 -07:00
Luke Parker
775824f373
Impl ScanData serialization in the DB
2024-09-19 23:36:32 -07:00
Luke Parker
41a74cb513
Check a queued key has never been queued before
...
Re-queueing should only happen with a malicious supermajority and breaks
indexing by the key.
2024-09-19 23:36:32 -07:00
Luke Parker
e26da1ec34
Have the Eventuality task drop outputs which aren't ours and aren't worth it to aggregate
...
We could drop these entirely, yet there's some degree of utility to be able to
add coins to Serai in this manner.
2024-09-19 23:36:32 -07:00
Luke Parker
7266e7f7ea
Add note on why LifetimeStage is monotonic
2024-09-19 23:36:32 -07:00
Luke Parker
a8b9b7bad3
Add sanity checks we haven't prior reported an InInstruction for/accumulated an output
2024-09-19 23:36:32 -07:00
Luke Parker
2ca7fccb08
Pass the lifetime information to the scheduler
...
Enables it to decide which keys to use for fulfillment/change.
2024-09-19 23:36:32 -07:00
Luke Parker
4f6d91037e
Call flush_key
2024-09-19 23:36:32 -07:00
Luke Parker
8db76ed67c
Add key management to the scheduler
2024-09-19 23:36:32 -07:00
Luke Parker
920303e1b4
Add helper to intake Eventualities
2024-09-19 23:36:32 -07:00
Luke Parker
9f4b28e5ae
Clarify output-to-self to output-to-Serai
...
There's only the requirement it's to an active key which is being reported for.
2024-09-19 23:36:32 -07:00
Luke Parker
f9d02d43c2
Route burns through the scanner
2024-09-19 23:36:32 -07:00
Luke Parker
8ac501028d
Add API to publish Batches with
...
This doesn't have to be abstract, we can generate the message and use the
message-queue API, yet this should help with testing.
2024-09-19 23:36:32 -07:00
Luke Parker
612c67c537
Cache the cost to aggregate
2024-09-19 23:36:32 -07:00
Luke Parker
04a971a024
Fill in various DB functions
2024-09-19 23:36:32 -07:00
Luke Parker
738636c238
Have Scanner::new spawn tasks
2024-09-19 23:36:32 -07:00
Luke Parker
65f3f48517
Add ReportDb
2024-09-19 23:36:32 -07:00
Luke Parker
7cc07d64d1
Make report.rs a folder, not a file
2024-09-19 23:36:32 -07:00
Luke Parker
fdfe520f9d
Add ScanDb
2024-09-19 23:36:32 -07:00
Luke Parker
77ef25416b
Make scan.rs a folder, not a file
2024-09-19 23:36:32 -07:00
Luke Parker
7c1025dbcb
Implement key retiry
2024-09-19 23:36:32 -07:00
Luke Parker
a771fbe1c6
Logs, documentation, misc
2024-09-19 23:36:32 -07:00