forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 105
Spv proof #1207
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
Merged
Merged
Spv proof #1207
Changes from 56 commits
Commits
Show all changes
82 commits
Select commit
Hold shift + click to select a range
b53c03d
feat(unit_tests): add begin of unit test for spv proof
Milerius 8b1ccc5
feat(utxo): continue test
Milerius b175b74
feat(unit_tests): very wip
Milerius 3c122b1
feat(utxo): merkle tree verification now work; need full refactoring
Milerius 971503a
feat(spv): start spv validation module
Milerius 6570e07
feat(spv): add spv proof
Milerius da81a73
feat(spv): add merkle proof unit test for a single element
Milerius c888b42
feat(spv): add complex merkle proof inclusion unit test
Milerius a97f4d1
feat(spv): fix some cargo warnings
Milerius f9f9708
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
Milerius 7f09afa
feat(spv): simplify error check for validate_spv_proof
Milerius b43aed6
feat(spv): complete the first step of the spv proof validation
Milerius 8265073
feat(spv): complete the unit test for spv proof validation in utxo mo…
Milerius 9176fd1
feat(spv_validation): add vin and vout check for spv proof validation
Milerius e80eafe
feat(spv_validation): match exact error from the spv - will customize…
Milerius a1940c1
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
Milerius 1e405bb
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
Milerius db324f7
feat(utxo): start utxo block header storage + sync with dev
Milerius 5fd7d6a
feat(utxo): continue block header storage interface
Milerius 773b27b
feat(utxo): revert sled - will switch to sqllite
Milerius b3b8750
feat(utxo): start utxo sql block header storage trait implementation
Milerius f3728f8
feat(sql): implement partially add_block_headers_to_storage and the u…
Milerius 5c408a8
feat(sql): add get_block header functions
Milerius d880ff8
feat(sql): add extra function for block insertion
Milerius b62ab5a
feat(lib_bitcoin): add raw header type
Milerius 3710ea7
feat(spv): Integrate raw block header into spv validation
Milerius 0a0eb47
feat(spv): remove old comments
Milerius deba4d0
feat(spv): Adding raw header into utxo_common spv validation
Milerius 5028d08
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-API…
Milerius 6bd7c36
feat(spv): make slp great again
Milerius 3f9dfb6
feat(spv): returning more concrete error types
Milerius 4c88900
feat(toolchain): update to `nightly-2022-02-01` to fix osx compilation
Milerius 2f25426
feat(cargo): fix warnings
Milerius 2368209
feat(fmt): rust fmt
Milerius 8914b76
feat(utxo_block_header): add a box dyn for block header storage to ut…
Milerius 1def807
Revert "feat(utxo_block_header): add a box dyn for block header stora…
Milerius f75aee9
feat(utxo): add empty utxo_indexedb_block_header_storage.rs
Milerius 40e3cf7
feat(utxo): start an empty loop for downloading headers
Milerius 4dedf0b
feat(indexed_db_block_header): do not use todo to prevent crash at ru…
Milerius b69e401
feat(dev): sync with dev
Milerius aab5c80
feat(block_header_loop): add block header loop in arc builder
Milerius 1db867d
feat(utxo): add a function to retrieve a storage from the ctx for blo…
Milerius 03e937b
feat(utxo): start logic of block header downloading, very WIP
Milerius 93a6505
feat(header_validation): add partial header validation + params for e…
Milerius de9478c
feat(header_validation): add unexpected difficulty change check
Milerius c36d9b0
feat(header_validation): add unit test for validate headers
Milerius 78fd499
feat(header_validation): document the validate_headers function
Milerius db57ce1
feat(header_validation): use appropriate error for validate_headers
Milerius 43b272a
feat(storage): rework storage to make it persistent
Milerius 7262e3f
feat(storage): use the block header storage as optional and fix unit …
Milerius f0aeecb
feat(storage): make the conf into coins settings
Milerius 6707b6a
feat(dev): sync with dev
Milerius 7a4c689
feat(storage): implement header from storage or rpc + within validation
Milerius 43a311c
feat(improvements): remove non-used function
Milerius 4e44bc3
feat(storage): add to storage after validation in retrieve header fro…
Milerius fa9d3e6
feat(dev): fix conflict
Milerius 2ccd242
feat(fix_review): first fixes batch
Milerius 33877d2
feat(fix_review): sql fixes + rename `from_address` to `sender_address`
Milerius b63dfd6
feat(fix_review): simplify the way to get height, use into_iter + find
Milerius 3fc93ec
feat(fix_review): add a get_tx_height function + remove more marketco…
Milerius 676d30c
feat(fix_review): simplify download_loop with a `try_loop` macro
Milerius e4504b4
feat(fix_review): improve get_tx_height
Milerius 900e62a
feat(fix_review): continue review improvements, move retrieve_last_he…
Milerius 1bba0df
feat(fix_review): remove dead code comment
Milerius a341fed
feat(spv): next batch of fixes
Milerius b998591
feat(review): remove utxo_wrapper_block_header_storage.rs
Milerius 36999e5
feat(review): next batche of fixes
Milerius dfd4bd4
feat(review): refactor block_header_from_storage_or_rpc
Milerius dfbfceb
feat(wasm): use explicitly instant wasm bindgen
Milerius 291b76e
feat(spv): fix wasm tests
Milerius 0e38525
feat(spv): fix unit test compilation
Milerius ed97f35
feat(eth): ignore polygon unit test (unstable)
Milerius 6621d5b
feat(unit tests): increase to 6 seconds for the docker unit test
Milerius 27a4e8b
feat(utxo): simplify block_headers_storage, add error
Milerius 863fcc2
feat(review): batch of review fixes
Milerius 0d09094
feat(review): another batch of review fixes
Milerius 5d19724
feat(eth_test): remove the loop
Milerius b071fcd
feat(eth_test): remove the loop
Milerius 3beaf24
feat(spv_proof): review fixes
Milerius 9c50442
feat(dev): sync with dev
Milerius b5cadc5
feat(spv_proof): review fixes
Milerius 4ff3f4f
feat(spv): fix wrong copy paste description
Milerius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use crate::utxo::rpc_clients::ElectrumBlockHeader; | ||
use async_trait::async_trait; | ||
use chain::BlockHeader; | ||
use common::mm_error::MmError; | ||
use derive_more::Display; | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, Deserialize, Display, Serialize, SerializeErrorType)] | ||
#[serde(tag = "error_type", content = "error_data")] | ||
pub enum BlockHeaderStorageError { | ||
artemii235 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[display(fmt = "The storage cannot be initialized for {}", _0)] | ||
InitializationError(String), | ||
sergeyboyko0791 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[display(fmt = "The storage is not initialized for {} - reason: {}", ticker, reason)] | ||
NotInitializedError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't add to the storage for {} - reason: {}", ticker, reason)] | ||
AddToStorageError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't add to the storage for {} - reason: {}", ticker, reason)] | ||
sergeyboyko0791 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GetFromStorageError { ticker: String, reason: String }, | ||
#[display( | ||
fmt = "Can't retrieve the table from the storage for {} - reason: {}", | ||
ticker, | ||
reason | ||
)] | ||
CantRetrieveTableError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't query from the storage - query: {} - reason: {}", query, reason)] | ||
QueryError { query: String, reason: String }, | ||
#[display(fmt = "Can't retrieve string from row - reason: {}", reason)] | ||
StringRowError { reason: String }, | ||
#[display(fmt = "Can't execute query from storage for {} - reason: {}", ticker, reason)] | ||
ExecutionError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't start a transaction from storage for {} - reason: {}", ticker, reason)] | ||
TransactionError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't commit a transaction from storage for {} - reason: {}", ticker, reason)] | ||
CommitError { ticker: String, reason: String }, | ||
#[display(fmt = "Can't decode/deserialize from storage for {} - reason: {}", ticker, reason)] | ||
DecodeError { ticker: String, reason: String }, | ||
} | ||
|
||
#[async_trait] | ||
pub trait BlockHeaderStorageOps: Send + Sync + 'static { | ||
/// Initializes collection/tables in storage for a specified coin | ||
async fn init(&self, for_coin: &str) -> Result<(), MmError<BlockHeaderStorageError>>; | ||
|
||
async fn is_initialized_for(&self, for_coin: &str) -> Result<bool, MmError<BlockHeaderStorageError>>; | ||
|
||
// Adds multiple block headers to the selected coin's header storage | ||
// Should store it as `TICKER_HEIGHT=hex_string` | ||
// use this function for headers that comes from `blockchain_headers_subscribe` | ||
async fn add_electrum_block_headers_to_storage( | ||
&self, | ||
for_coin: &str, | ||
headers: Vec<ElectrumBlockHeader>, | ||
) -> Result<(), MmError<BlockHeaderStorageError>>; | ||
|
||
// Adds multiple block headers to the selected coin's header storage | ||
// Should store it as `TICKER_HEIGHT=hex_string` | ||
// use this function for headers that comes from `blockchain_block_headers` | ||
async fn add_block_headers_to_storage( | ||
&self, | ||
for_coin: &str, | ||
headers: HashMap<u64, BlockHeader>, | ||
) -> Result<(), MmError<BlockHeaderStorageError>>; | ||
|
||
/// Gets the block header by height from the selected coin's storage as BlockHeader | ||
async fn get_block_header( | ||
&self, | ||
for_coin: &str, | ||
height: u64, | ||
) -> Result<Option<BlockHeader>, MmError<BlockHeaderStorageError>>; | ||
|
||
/// Gets the block header by height from the selected coin's storage as hex | ||
async fn get_block_header_raw( | ||
&self, | ||
for_coin: &str, | ||
height: u64, | ||
) -> Result<Option<String>, MmError<BlockHeaderStorageError>>; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.