very rough block manager
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled

This commit is contained in:
Boog900 2024-08-23 23:55:54 +01:00
parent f909c262fa
commit f25588d348
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
20 changed files with 965 additions and 49 deletions

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

637
.idea/workspace.xml Normal file
View file

@ -0,0 +1,637 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="ALL" />
</component>
<component name="CargoProjects">
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="d1032f99-e09e-480f-a744-beb0ea7b1d5e" name="Changes" comment="`PId` -&gt; `PeerId`">
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/blockchain.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/blockchain.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/blockchain/manager.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/blockchain/manager.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/blockchain/manager/batch_handler.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/blockchain/manager/batch_handler.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/p2p.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/p2p.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/binaries/cuprated/src/p2p/request_handler.rs" beforeDir="false" afterPath="$PROJECT_DIR$/binaries/cuprated/src/p2p/request_handler.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/consensus/src/block.rs" beforeDir="false" afterPath="$PROJECT_DIR$/consensus/src/block.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/consensus/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/consensus/src/lib.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/consensus/src/transactions.rs" beforeDir="false" afterPath="$PROJECT_DIR$/consensus/src/transactions.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/consensus/src/transactions/free.rs" beforeDir="false" afterPath="$PROJECT_DIR$/consensus/src/transactions/free.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/p2p/p2p-core/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/p2p/p2p-core/src/lib.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/p2p/p2p/src/config.rs" beforeDir="false" afterPath="$PROJECT_DIR$/p2p/p2p/src/config.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/p2p/p2p/src/lib.rs" beforeDir="false" afterPath="$PROJECT_DIR$/p2p/p2p/src/lib.rs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Rust File" />
</list>
</option>
</component>
<component name="FormatOnSaveOptions">
<option name="myRunOnSave" value="true" />
<option name="myAllFileTypesSelected" value="false" />
<option name="mySelectedFileTypes">
<set>
<option value="CSS" />
<option value="DTD" />
<option value="ECMAScript 6" />
<option value="Flow" />
<option value="HTML" />
<option value="HTTP Request" />
<option value="JSHint" />
<option value="JSON" />
<option value="JSON-lines" />
<option value="JSON5" />
<option value="JSX Harmony" />
<option value="JavaScript" />
<option value="Markdown" />
<option value="NatVis" />
<option value="QmlType" />
<option value="Qt UI file" />
<option value="RNG Compact" />
<option value="Rust" />
<option value="SVG" />
<option value="Shell Script" />
<option value="TypeScript" />
<option value="TypeScript JSX" />
<option value="XHTML" />
<option value="XML" />
<option value="YAML" />
<option value="qrc" />
<option value="tsconfig" />
</set>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="proto-req-hdlr" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/storage/txpool/src/service/write.rs" root0="SKIP_INSPECTION" />
</component>
<component name="MacroExpansionManager">
<option name="directoryName" value="r6zcvbq1" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 4
}</component>
<component name="ProjectId" id="2kFBaFNVkzv8EcH0EAfSrXZRAks" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Cargo.Doctest of ops (line 34).executor": "Run",
"Cargo.Doctest of service (line 62).executor": "Run",
"Cargo.Run cuprated.executor": "Debug",
"Cargo.Test pool::incoming_tx::tests::test_builder.executor": "Run",
"Cargo.Test test.executor": "Debug",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.rust.reset.selective.auto.import": "true",
"git-widget-placeholder": "cuprated-blockchain",
"node.js.detected.package.eslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
"org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",
"settings.editor.selected.configurable": "actions.on.save"
}
}]]></component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/binaries/cuprated/src/p2p" />
<recent name="$PROJECT_DIR$/storage/blockchain/src" />
</key>
</component>
<component name="RsExternalLinterProjectSettings">
<option name="runOnTheFly" value="true" />
<option name="tool" value="Clippy" />
</component>
<component name="RunManager" selected="Cargo.Run cuprated">
<configuration name="Run cuprated" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="run --package cuprated --bin cuprated" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test p2p::admin::tests::serde_handshake_res" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package monero-wire --lib p2p::admin::tests::serde_handshake_res -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test p2p_handshake" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package epee-encoding --test p2p p2p_handshake -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test rpc::client::tests::tt" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package cuprate-test-utils --lib rpc::client::tests::tt -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<configuration name="Test test" type="CargoCommandRunConfiguration" factoryName="Cargo Command" temporary="true">
<option name="command" value="test --package cuprate-epee-encoding --test tt test -- --exact" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
<envs />
<option name="emulateTerminal" value="true" />
<option name="channel" value="DEFAULT" />
<option name="requiredFeatures" value="true" />
<option name="allFeatures" value="false" />
<option name="withSudo" value="false" />
<option name="buildTarget" value="REMOTE" />
<option name="backtrace" value="SHORT" />
<option name="isRedirectInput" value="false" />
<option name="redirectInputPath" value="" />
<method v="2">
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<recent_temporary>
<list>
<item itemvalue="Cargo.Run cuprated" />
<item itemvalue="Cargo.Test test" />
<item itemvalue="Cargo.Test rpc::client::tests::tt" />
<item itemvalue="Cargo.Test p2p_handshake" />
<item itemvalue="Cargo.Test p2p::admin::tests::serde_handshake_res" />
</list>
</recent_temporary>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
<component name="RustfmtProjectSettings">
<option name="useRustfmt" value="true" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="d1032f99-e09e-480f-a744-beb0ea7b1d5e" name="Changes" comment="`bc` -&gt; `blockchain`" />
<created>1722869508802</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1722869508802</updated>
<workItem from="1722869510290" duration="81000" />
<workItem from="1722869600374" duration="26571000" />
<workItem from="1722955003374" duration="24174000" />
<workItem from="1723037908706" duration="17266000" />
<workItem from="1723122880698" duration="21168000" />
<workItem from="1723218016483" duration="15810000" />
<workItem from="1723249920813" duration="3297000" />
<workItem from="1723332579446" duration="912000" />
<workItem from="1723409128770" duration="3156000" />
<workItem from="1723468396917" duration="21588000" />
<workItem from="1723559211981" duration="10367000" />
<workItem from="1723591724462" duration="5241000" />
<workItem from="1723643320504" duration="15530000" />
<workItem from="1723723944792" duration="29923000" />
<workItem from="1723814422068" duration="17808000" />
<workItem from="1723925675252" duration="10774000" />
<workItem from="1724018660196" duration="2078000" />
<workItem from="1724072530739" duration="28867000" />
<workItem from="1724161208151" duration="26928000" />
<workItem from="1724249809783" duration="14832000" />
<workItem from="1724333484896" duration="8324000" />
<workItem from="1724418469082" duration="13533000" />
<workItem from="1724439928196" duration="8647000" />
</task>
<task id="LOCAL-00001" summary="`bc` -&gt; `blockchain`">
<option name="closed" value="true" />
<created>1722869881493</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1722869881493</updated>
</task>
<task id="LOCAL-00002" summary="doc fixes">
<option name="closed" value="true" />
<created>1722870056808</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1722870056808</updated>
</task>
<task id="LOCAL-00003" summary="cargo fmt">
<option name="closed" value="true" />
<created>1722870767745</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1722870767745</updated>
</task>
<task id="LOCAL-00004" summary="cargo fmt">
<option name="closed" value="true" />
<created>1722871328779</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1722871328779</updated>
</task>
<task id="LOCAL-00005" summary="add more docs">
<option name="closed" value="true" />
<created>1722906207310</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1722906207310</updated>
</task>
<task id="LOCAL-00006" summary="fixes">
<option name="closed" value="true" />
<created>1722907656548</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1722907656548</updated>
</task>
<task id="LOCAL-00007" summary="move `HardFork` to `types`">
<option name="closed" value="true" />
<created>1722992299543</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1722992299543</updated>
</task>
<task id="LOCAL-00008" summary="fmt">
<option name="closed" value="true" />
<created>1722992779351</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1722992779351</updated>
</task>
<task id="LOCAL-00009" summary="fix tests &amp; doc">
<option name="closed" value="true" />
<created>1722994414575</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1722994414575</updated>
</task>
<task id="LOCAL-00010" summary="fix clippy">
<option name="closed" value="true" />
<created>1723040367937</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1723040367937</updated>
</task>
<task id="LOCAL-00011" summary="move transaction verification data">
<option name="closed" value="true" />
<created>1723125824866</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1723125824866</updated>
</task>
<task id="LOCAL-00012" summary="misc fixes">
<option name="closed" value="true" />
<created>1723127416195</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1723127416195</updated>
</task>
<task id="LOCAL-00013" summary="doc fixes">
<option name="closed" value="true" />
<created>1723133261401</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1723133261401</updated>
</task>
<task id="LOCAL-00014" summary="start proptest arbitrary chain">
<option name="closed" value="true" />
<created>1723148800683</created>
<option name="number" value="00014" />
<option name="presentableId" value="LOCAL-00014" />
<option name="project" value="LOCAL" />
<updated>1723148800683</updated>
</task>
<task id="LOCAL-00015" summary="update README.md">
<option name="closed" value="true" />
<created>1723159166301</created>
<option name="number" value="00015" />
<option name="presentableId" value="LOCAL-00015" />
<option name="project" value="LOCAL" />
<updated>1723159166301</updated>
</task>
<task id="LOCAL-00016" summary="review fixes">
<option name="closed" value="true" />
<created>1723159709038</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1723159709038</updated>
</task>
<task id="LOCAL-00017" summary="add write functions + docs">
<option name="closed" value="true" />
<created>1723225457199</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1723225457199</updated>
</task>
<task id="LOCAL-00018" summary="fix merge">
<option name="closed" value="true" />
<created>1723249397528</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1723249397528</updated>
</task>
<task id="LOCAL-00019" summary="fix test">
<option name="closed" value="true" />
<created>1723250798381</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1723250798381</updated>
</task>
<task id="LOCAL-00020" summary="fix ci">
<option name="closed" value="true" />
<created>1723251564499</created>
<option name="number" value="00020" />
<option name="presentableId" value="LOCAL-00020" />
<option name="project" value="LOCAL" />
<updated>1723251564499</updated>
</task>
<task id="LOCAL-00021" summary="move `TxPoolWriteError`">
<option name="closed" value="true" />
<created>1723251946498</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1723251946498</updated>
</task>
<task id="LOCAL-00022" summary="add more docs">
<option name="closed" value="true" />
<created>1723499207124</created>
<option name="number" value="00022" />
<option name="presentableId" value="LOCAL-00022" />
<option name="project" value="LOCAL" />
<updated>1723499207124</updated>
</task>
<task id="LOCAL-00023" summary="fix toml formatting">
<option name="closed" value="true" />
<created>1723500679410</created>
<option name="number" value="00023" />
<option name="presentableId" value="LOCAL-00023" />
<option name="project" value="LOCAL" />
<updated>1723500679410</updated>
</task>
<task id="LOCAL-00024" summary="fix some docs">
<option name="closed" value="true" />
<created>1723500847360</created>
<option name="number" value="00024" />
<option name="presentableId" value="LOCAL-00024" />
<option name="project" value="LOCAL" />
<updated>1723500847360</updated>
</task>
<task id="LOCAL-00025" summary="fix clippy">
<option name="closed" value="true" />
<created>1723501335763</created>
<option name="number" value="00025" />
<option name="presentableId" value="LOCAL-00025" />
<option name="project" value="LOCAL" />
<updated>1723501335763</updated>
</task>
<task id="LOCAL-00026" summary="init">
<option name="closed" value="true" />
<created>1723512507585</created>
<option name="number" value="00026" />
<option name="presentableId" value="LOCAL-00026" />
<option name="project" value="LOCAL" />
<updated>1723512507585</updated>
</task>
<task id="LOCAL-00027" summary="reduce the jobs handled by the dandelion pool">
<option name="closed" value="true" />
<created>1723767027153</created>
<option name="number" value="00027" />
<option name="presentableId" value="LOCAL-00027" />
<option name="project" value="LOCAL" />
<updated>1723767027153</updated>
</task>
<task id="LOCAL-00028" summary="fix docs">
<option name="closed" value="true" />
<created>1723767615139</created>
<option name="number" value="00028" />
<option name="presentableId" value="LOCAL-00028" />
<option name="project" value="LOCAL" />
<updated>1723767615139</updated>
</task>
<task id="LOCAL-00029" summary="resolve todo">
<option name="closed" value="true" />
<created>1723768785884</created>
<option name="number" value="00029" />
<option name="presentableId" value="LOCAL-00029" />
<option name="project" value="LOCAL" />
<updated>1723768785884</updated>
</task>
<task id="LOCAL-00030" summary="add cuprated skeleton">
<option name="closed" value="true" />
<created>1723771471205</created>
<option name="number" value="00030" />
<option name="presentableId" value="LOCAL-00030" />
<option name="project" value="LOCAL" />
<updated>1723771471205</updated>
</task>
<task id="LOCAL-00031" summary="fmt and add deny exception">
<option name="closed" value="true" />
<created>1723816913395</created>
<option name="number" value="00031" />
<option name="presentableId" value="LOCAL-00031" />
<option name="project" value="LOCAL" />
<updated>1723816913395</updated>
</task>
<task id="LOCAL-00032" summary="add main chain batch handler">
<option name="closed" value="true" />
<created>1724168407863</created>
<option name="number" value="00032" />
<option name="presentableId" value="LOCAL-00032" />
<option name="project" value="LOCAL" />
<updated>1724168407864</updated>
</task>
<task id="LOCAL-00033" summary="add blockchain init">
<option name="closed" value="true" />
<created>1724252529611</created>
<option name="number" value="00033" />
<option name="presentableId" value="LOCAL-00033" />
<option name="project" value="LOCAL" />
<updated>1724252529611</updated>
</task>
<task id="LOCAL-00034" summary="review changes">
<option name="closed" value="true" />
<created>1724253642047</created>
<option name="number" value="00034" />
<option name="presentableId" value="LOCAL-00034" />
<option name="project" value="LOCAL" />
<updated>1724253642047</updated>
</task>
<task id="LOCAL-00035" summary="review fixes">
<option name="closed" value="true" />
<created>1724254915004</created>
<option name="number" value="00035" />
<option name="presentableId" value="LOCAL-00035" />
<option name="project" value="LOCAL" />
<updated>1724254915004</updated>
</task>
<task id="LOCAL-00036" summary="update docs">
<option name="closed" value="true" />
<created>1724255395365</created>
<option name="number" value="00036" />
<option name="presentableId" value="LOCAL-00036" />
<option name="project" value="LOCAL" />
<updated>1724255395365</updated>
</task>
<task id="LOCAL-00037" summary="fix merge">
<option name="closed" value="true" />
<created>1724255786382</created>
<option name="number" value="00037" />
<option name="presentableId" value="LOCAL-00037" />
<option name="project" value="LOCAL" />
<updated>1724255786382</updated>
</task>
<task id="LOCAL-00038" summary="fix docs">
<option name="closed" value="true" />
<created>1724258898859</created>
<option name="number" value="00038" />
<option name="presentableId" value="LOCAL-00038" />
<option name="project" value="LOCAL" />
<updated>1724258898859</updated>
</task>
<task id="LOCAL-00039" summary="fix tests">
<option name="closed" value="true" />
<created>1724267338063</created>
<option name="number" value="00039" />
<option name="presentableId" value="LOCAL-00039" />
<option name="project" value="LOCAL" />
<updated>1724267338063</updated>
</task>
<task id="LOCAL-00040" summary="fix tests">
<option name="closed" value="true" />
<created>1724282276348</created>
<option name="number" value="00040" />
<option name="presentableId" value="LOCAL-00040" />
<option name="project" value="LOCAL" />
<updated>1724282276348</updated>
</task>
<task id="LOCAL-00041" summary="`PId` -&gt; `PeerId`">
<option name="closed" value="true" />
<created>1724282489662</created>
<option name="number" value="00041" />
<option name="presentableId" value="LOCAL-00041" />
<option name="project" value="LOCAL" />
<updated>1724282489662</updated>
</task>
<task id="LOCAL-00042" summary="`PId` -&gt; `PeerId`">
<option name="closed" value="true" />
<created>1724282501646</created>
<option name="number" value="00042" />
<option name="presentableId" value="LOCAL-00042" />
<option name="project" value="LOCAL" />
<updated>1724282501646</updated>
</task>
<task id="LOCAL-00043" summary="`PId` -&gt; `PeerId`">
<option name="closed" value="true" />
<created>1724282545275</created>
<option name="number" value="00043" />
<option name="presentableId" value="LOCAL-00043" />
<option name="project" value="LOCAL" />
<updated>1724282545275</updated>
</task>
<option name="localTasksCounter" value="44" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="doc fixes" />
<MESSAGE value="start proptest arbitrary chain" />
<MESSAGE value="update README.md" />
<MESSAGE value="add write functions + docs" />
<MESSAGE value="fix test" />
<MESSAGE value="fix ci" />
<MESSAGE value="move `TxPoolWriteError`" />
<MESSAGE value="add more docs" />
<MESSAGE value="fix toml formatting" />
<MESSAGE value="fix some docs" />
<MESSAGE value="fix clippy" />
<MESSAGE value="init" />
<MESSAGE value="reduce the jobs handled by the dandelion pool" />
<MESSAGE value="resolve todo" />
<MESSAGE value="add cuprated skeleton" />
<MESSAGE value="fmt and add deny exception" />
<MESSAGE value="add main chain batch handler" />
<MESSAGE value="add blockchain init" />
<MESSAGE value="review changes" />
<MESSAGE value="review fixes" />
<MESSAGE value="update docs" />
<MESSAGE value="fix merge" />
<MESSAGE value="fix docs" />
<MESSAGE value="fix tests" />
<MESSAGE value="`PId` -&gt; `PeerId`" />
<option name="LAST_COMMIT_MESSAGE" value="`PId` -&gt; `PeerId`" />
</component>
</project>

80
Cargo.lock generated
View file

@ -939,6 +939,7 @@ dependencies = [
"clap",
"cuprate-blockchain",
"cuprate-consensus",
"cuprate-cryptonight",
"cuprate-p2p",
"cuprate-p2p-core",
"cuprate-types",
@ -949,6 +950,7 @@ dependencies = [
"tokio",
"tower",
"tracing",
"tracing-subscriber",
]
[[package]]
@ -983,7 +985,7 @@ dependencies = [
[[package]]
name = "dalek-ff-group"
version = "0.4.1"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"crypto-bigint",
"curve25519-dalek",
@ -1138,7 +1140,7 @@ dependencies = [
[[package]]
name = "flexible-transcript"
version = "0.3.2"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"blake2",
"digest",
@ -1802,7 +1804,7 @@ dependencies = [
[[package]]
name = "monero-address"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"monero-io",
@ -1815,7 +1817,7 @@ dependencies = [
[[package]]
name = "monero-borromean"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"monero-generators",
@ -1828,7 +1830,7 @@ dependencies = [
[[package]]
name = "monero-bulletproofs"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"monero-generators",
@ -1843,7 +1845,7 @@ dependencies = [
[[package]]
name = "monero-clsag"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
@ -1863,7 +1865,7 @@ dependencies = [
[[package]]
name = "monero-generators"
version = "0.4.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"dalek-ff-group",
@ -1877,7 +1879,7 @@ dependencies = [
[[package]]
name = "monero-io"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"std-shims",
@ -1886,7 +1888,7 @@ dependencies = [
[[package]]
name = "monero-mlsag"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"monero-generators",
@ -1900,7 +1902,7 @@ dependencies = [
[[package]]
name = "monero-primitives"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"monero-generators",
@ -1913,7 +1915,7 @@ dependencies = [
[[package]]
name = "monero-rpc"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"async-trait",
"curve25519-dalek",
@ -1930,7 +1932,7 @@ dependencies = [
[[package]]
name = "monero-serai"
version = "0.1.4-alpha"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"curve25519-dalek",
"hex-literal",
@ -1948,7 +1950,7 @@ dependencies = [
[[package]]
name = "monero-simple-request-rpc"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"async-trait",
"digest_auth",
@ -1958,6 +1960,16 @@ dependencies = [
"tokio",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@ -2005,6 +2017,12 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "page_size"
version = "0.6.0"
@ -2607,6 +2625,15 @@ dependencies = [
"keccak",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
@ -2619,7 +2646,7 @@ dependencies = [
[[package]]
name = "simple-request"
version = "0.1.0"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"http-body-util",
"hyper",
@ -2675,7 +2702,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "std-shims"
version = "0.1.1"
source = "git+https://github.com/Cuprate/serai.git?rev=d5205ce#d5205ce2319e09414eb91d12cf38e83a08165f79"
source = "git+https://github.com/Cuprate/serai.git?rev=50686e8#50686e84022edbd0065d2af655ea4aa5faf486b8"
dependencies = [
"hashbrown",
"spin",
@ -2974,6 +3001,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
@ -2982,7 +3021,12 @@ version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
@ -3062,6 +3106,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "version_check"
version = "0.9.4"

View file

@ -65,7 +65,7 @@ futures = { version = "0.3.29", default-features = false }
hex = { version = "0.4.3", default-features = false }
hex-literal = { version = "0.4", default-features = false }
indexmap = { version = "2.2.5", default-features = false }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce", default-features = false }
monero-serai = { git = "https://github.com/Cuprate/serai.git", rev = "50686e8", default-features = false }
paste = { version = "1.0.14", default-features = false }
pin-project = { version = "1.1.3", default-features = false }
randomx-rs = { git = "https://github.com/Cuprate/randomx-rs.git", rev = "0028464", default-features = false }
@ -85,8 +85,8 @@ tracing-subscriber = { version = "0.3.17", default-features = false }
tracing = { version = "0.1.40", default-features = false }
## workspace.dev-dependencies
monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "d5205ce" }
monero-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "50686e8" }
monero-simple-request-rpc = { git = "https://github.com/Cuprate/serai.git", rev = "50686e8" }
tempfile = { version = "3" }
pretty_assertions = { version = "1.4.0" }
proptest = { version = "1" }

View file

@ -13,6 +13,7 @@ cuprate-blockchain = { path = "../../storage/blockchain" }
cuprate-p2p = { path = "../../p2p/p2p" }
cuprate-p2p-core = { path = "../../p2p/p2p-core" }
cuprate-types = { path = "../../types" }
cuprate-cryptonight = { path = "../../cryptonight" }
rayon = { workspace = true }
futures = { workspace = true }
@ -23,6 +24,13 @@ thiserror = { workspace = true }
hex = { workspace = true }
clap = { workspace = true, features = ["default", "derive"] }
tracing-subscriber = { workspace = true, features = ["default"] }
#[lints]
#workspace = true
[profile.dev]
panic = 'abort'
[profile.release]
panic = 'abort'

View file

@ -8,18 +8,64 @@ use crate::blockchain::types::{
ConsensusBlockchainReadHandle,
};
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
use cuprate_consensus::{
BlockChainContextService, BlockVerifierService, ContextConfig, TxVerifierService,
};
use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig};
use cuprate_cryptonight::cryptonight_hash_v0;
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
use cuprate_p2p::NetworkInterface;
use cuprate_p2p_core::ClearNet;
use cuprate_p2p_core::{ClearNet, Network};
use cuprate_types::blockchain::{
BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest,
};
use cuprate_types::VerifiedBlockInformation;
use tokio::sync::mpsc;
use tower::{Service, ServiceExt};
mod manager;
mod syncer;
mod types;
pub async fn check_add_genesis(
blockchain_read_handle: &mut BlockchainReadHandle,
blockchain_write_handle: &mut BlockchainWriteHandle,
network: &Network,
) {
if blockchain_read_handle
.ready()
.await
.unwrap()
.call(BlockchainReadRequest::ChainHeight)
.await
.is_ok()
{
return;
}
let genesis = generate_genesis_block(network);
blockchain_write_handle
.ready()
.await
.unwrap()
.call(BlockchainWriteRequest::WriteBlock(
VerifiedBlockInformation {
block_blob: genesis.serialize(),
txs: vec![],
block_hash: genesis.hash(),
pow_hash: cryptonight_hash_v0(&genesis.serialize_pow_hash()),
height: 0,
generated_coins: genesis.miner_transaction.prefix().outputs[0]
.amount
.unwrap(),
weight: genesis.miner_transaction.weight(),
long_term_weight: genesis.miner_transaction.weight(),
cumulative_difficulty: 1,
block: genesis,
},
))
.await
.unwrap();
}
pub async fn init_consensus(
blockchain_read_handle: BlockchainReadHandle,
context_config: ContextConfig,

View file

@ -39,18 +39,20 @@ impl BlockchainManager {
}
pub async fn run(mut self, mut batch_rx: Receiver<BlockBatch>) {
tokio::select! {
Some(batch) = batch_rx.recv() => {
handle_incoming_block_batch(
batch,
&mut self.block_verifier_service,
&mut self.blockchain_context_service,
&mut self.blockchain_read_handle,
&mut self.blockchain_write_handle
).await;
}
else => {
todo!("Exit the BC manager")
loop {
tokio::select! {
Some(batch) = batch_rx.recv() => {
handle_incoming_block_batch(
batch,
&mut self.block_verifier_service,
&mut self.blockchain_context_service,
&mut self.blockchain_read_handle,
&mut self.blockchain_write_handle
).await;
}
else => {
todo!("TODO: exit the BC manager")
}
}
}
}

View file

@ -41,6 +41,16 @@ pub async fn handle_incoming_block_batch<C, TxV>(
.first()
.expect("Block batch should not be empty");
handle_incoming_block_batch_main_chain(
batch,
block_verifier_service,
blockchain_context_service,
blockchain_write_handle,
)
.await;
// TODO: alt block to the DB
/*
match blockchain_read_handle
.oneshot(BlockchainReadRequest::FindBlock(
first_block.header.previous,
@ -67,6 +77,8 @@ pub async fn handle_incoming_block_batch<C, TxV>(
Ok(_) => panic!("Blockchain service returned incorrect response"),
}
*/
}
async fn handle_incoming_block_batch_main_chain<C, TxV>(
@ -90,7 +102,12 @@ async fn handle_incoming_block_batch_main_chain<C, TxV>(
+ 'static,
TxV::Future: Send + 'static,
{
let Ok(VerifyBlockResponse::MainChainBatchPrepped(prepped)) = block_verifier_service
info!(
"Handling batch to main chain height: {}",
batch.blocks.first().unwrap().0.number().unwrap()
);
let VerifyBlockResponse::MainChainBatchPrepped(prepped) = block_verifier_service
.ready()
.await
.expect("TODO")
@ -98,21 +115,21 @@ async fn handle_incoming_block_batch_main_chain<C, TxV>(
blocks: batch.blocks,
})
.await
.unwrap()
else {
info!("Error verifying batch, banning peer");
todo!()
panic!("Incorrect response!");
};
for (block, txs) in prepped {
let Ok(VerifyBlockResponse::MainChain(verified_block)) = block_verifier_service
let VerifyBlockResponse::MainChain(verified_block) = block_verifier_service
.ready()
.await
.expect("TODO")
.call(VerifyBlockRequest::MainChainPrepped { block, txs })
.await
.unwrap()
else {
info!("Error verifying batch, banning peer");
todo!()
panic!("Incorrect response!");
};
blockchain_context_service

View file

@ -1,4 +1,10 @@
use crate::blockchain::check_add_genesis;
use clap::Parser;
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
use cuprate_p2p::P2PConfig;
use cuprate_p2p_core::Network;
use std::time::Duration;
use tracing::Level;
mod blockchain;
mod config;
@ -11,7 +17,11 @@ struct Args {}
fn main() {
let _args = Args::parse();
let (bc_read_handle, bc_write_handle, _) =
tracing_subscriber::fmt()
.with_max_level(Level::DEBUG)
.init();
let (mut bc_read_handle, mut bc_write_handle, _) =
cuprate_blockchain::service::init(cuprate_blockchain::config::Config::default()).unwrap();
let async_rt = tokio::runtime::Builder::new_multi_thread()
@ -20,13 +30,38 @@ fn main() {
.unwrap();
async_rt.block_on(async move {
let (block_verifier, tx_verifier, context_svc) = blockchain::init_consensus(
bc_read_handle,
check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await;
let (block_verifier, _tx_verifier, context_svc) = blockchain::init_consensus(
bc_read_handle.clone(),
cuprate_consensus::ContextConfig::main_net(),
)
.await
.unwrap();
//blockchain::init_blockchain_manager()
let net = cuprate_p2p::initialize_network(
p2p::request_handler::P2pProtocolRequestHandler,
p2p::core_sync_svc::CoreSyncService(context_svc.clone()),
p2p::dummy_config(),
)
.await
.unwrap();
blockchain::init_blockchain_manager(
net,
BlockDownloaderConfig {
buffer_size: 50_000_000,
in_progress_queue_size: 50_000_000,
check_client_pool_interval: Duration::from_secs(45),
target_batch_size: 10_000_000,
initial_batch_size: 1,
},
bc_write_handle,
bc_read_handle,
context_svc,
block_verifier,
);
tokio::time::sleep(Duration::MAX).await;
});
}

View file

@ -2,4 +2,28 @@
//!
//! Will handle initiating the P2P and contains a protocol request handler.
mod request_handler;
use cuprate_p2p::AddressBookConfig;
use cuprate_p2p_core::Network;
use std::time::Duration;
pub mod core_sync_svc;
pub mod request_handler;
pub fn dummy_config<N: cuprate_p2p_core::NetworkZone>() -> cuprate_p2p::P2PConfig<N> {
cuprate_p2p::P2PConfig {
network: Network::Mainnet,
outbound_connections: 64,
extra_outbound_connections: 0,
max_inbound_connections: 0,
gray_peers_percent: 0.7,
server_config: None,
p2p_port: 0,
rpc_port: 0,
address_book_config: AddressBookConfig {
max_white_list_length: 1000,
max_gray_list_length: 5000,
peer_store_file: "p2p_state.bin".into(),
peer_save_period: Duration::from_secs(60),
},
}
}

View file

@ -0,0 +1,51 @@
use cuprate_blockchain::cuprate_database::RuntimeError;
use cuprate_blockchain::service::BlockchainReadHandle;
use cuprate_consensus::{
BlockChainContextRequest, BlockChainContextResponse, BlockChainContextService,
};
use cuprate_p2p_core::services::{CoreSyncDataRequest, CoreSyncDataResponse};
use cuprate_p2p_core::CoreSyncData;
use cuprate_types::blockchain::BlockchainReadRequest;
use futures::future::{BoxFuture, MapErr, MapOk};
use futures::{FutureExt, TryFutureExt};
use std::task::{Context, Poll};
use tower::Service;
#[derive(Clone)]
pub struct CoreSyncService(pub BlockChainContextService);
impl Service<CoreSyncDataRequest> for CoreSyncService {
type Response = CoreSyncDataResponse;
type Error = tower::BoxError;
type Future = MapOk<
<BlockChainContextService as Service<BlockChainContextRequest>>::Future,
fn(BlockChainContextResponse) -> CoreSyncDataResponse,
>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
self.0.poll_ready(cx)
}
fn call(&mut self, _: CoreSyncDataRequest) -> Self::Future {
self.0
.call(BlockChainContextRequest::GetContext)
.map_ok(|res| {
let BlockChainContextResponse::Context(ctx) = res else {
panic!("blockchain context service returned wrong response.");
};
let raw_ctx = ctx.unchecked_blockchain_context();
// TODO: the hardfork here should be the version of the top block not the current HF,
// on HF boundaries these will be different.
CoreSyncDataResponse(CoreSyncData::new(
raw_ctx.cumulative_difficulty,
// TODO:
raw_ctx.chain_height as u64,
0,
raw_ctx.top_hash,
raw_ctx.current_hf.as_u8(),
))
})
}
}

View file

@ -1 +1,33 @@
use cuprate_p2p_core::{ProtocolRequest, ProtocolResponse};
use futures::future::BoxFuture;
use futures::FutureExt;
use std::task::{Context, Poll};
use tower::Service;
use tracing::trace;
#[derive(Clone)]
pub struct P2pProtocolRequestHandler;
impl Service<ProtocolRequest> for P2pProtocolRequestHandler {
type Response = ProtocolResponse;
type Error = tower::BoxError;
type Future = BoxFuture<'static, Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: ProtocolRequest) -> Self::Future {
match req {
ProtocolRequest::GetObjects(_) => trace!("TODO: GetObjects"),
ProtocolRequest::GetChain(_) => trace!("TODO: GetChain"),
ProtocolRequest::FluffyMissingTxs(_) => trace!("TODO: FluffyMissingTxs"),
ProtocolRequest::GetTxPoolCompliment(_) => trace!("TODO: GetTxPoolCompliment"),
ProtocolRequest::NewBlock(_) => trace!("TODO: NewBlock"),
ProtocolRequest::NewFluffyBlock(_) => trace!("TODO: NewFluffyBlock"),
ProtocolRequest::NewTransactions(_) => trace!("TODO: NewTransactions"),
}
async { Ok(ProtocolResponse::NA) }.boxed()
}
}

View file

@ -123,7 +123,7 @@ impl PreparedBlock {
///
/// The randomX VM must be Some if RX is needed or this will panic.
/// The randomX VM must also be initialised with the correct seed.
fn new<R: RandomX>(
pub fn new<R: RandomX>(
block: Block,
randomx_vm: Option<&R>,
) -> Result<PreparedBlock, ConsensusError> {

View file

@ -27,6 +27,7 @@ pub use context::{
pub use transactions::{TxVerifierService, VerifyTxRequest, VerifyTxResponse};
// re-export.
pub use cuprate_consensus_rules::genesis::generate_genesis_block;
pub use cuprate_types::blockchain::{BlockchainReadRequest, BlockchainResponse};
/// An Error returned from one of the consensus services.

View file

@ -393,6 +393,10 @@ async fn verify_transactions_decoy_info<D>(
where
D: Database + Clone + Sync + Send + 'static,
{
if hf == HardFork::V1 {
return Ok(());
}
batch_get_decoy_info(&txs, hf, database)
.await?
.try_for_each(|decoy_info| decoy_info.and_then(|di| Ok(check_decoy_info(&di, &hf)?)))?;

View file

@ -78,7 +78,8 @@ pub fn tx_fee(tx: &Transaction) -> Result<u64, TransactionError> {
}
for output in &prefix.outputs {
fee.checked_sub(output.amount.unwrap_or(0))
fee = fee
.checked_sub(output.amount.unwrap_or(0))
.ok_or(TransactionError::OutputsTooHigh)?;
}
}

View file

@ -79,6 +79,7 @@ pub use protocol::*;
use services::*;
//re-export
pub use cuprate_helper::network::Network;
pub use cuprate_wire::CoreSyncData;
/// The direction of a connection.
#[derive(Debug, Copy, Clone, Eq, PartialEq)]

View file

@ -1,8 +1,9 @@
use cuprate_address_book::AddressBookConfig;
use cuprate_helper::network::Network;
use cuprate_p2p_core::NetworkZone;
use cuprate_wire::{common::PeerSupportFlags, BasicNodeData};
pub use cuprate_address_book::AddressBookConfig;
/// P2P config.
#[derive(Clone, Debug)]
pub struct P2PConfig<N: NetworkZone> {

View file

@ -33,7 +33,7 @@ mod sync_states;
use block_downloader::{BlockBatch, BlockDownloaderConfig, ChainSvcRequest, ChainSvcResponse};
pub use broadcast::{BroadcastRequest, BroadcastSvc};
use client_pool::ClientPoolDropGuard;
pub use config::P2PConfig;
pub use config::{AddressBookConfig, P2PConfig};
use connection_maintainer::MakeConnectionRequest;
/// Initializes the P2P [`NetworkInterface`] for a specific [`NetworkZone`].

BIN
p2p_state.bin Normal file

Binary file not shown.