spacemeshos / protocol Goto Github PK
View Code? Open in Web Editor NEWThis repo contains the Spacemesh protocol specifications and related documentation
Home Page: http://protocol.spacemesh.io/
License: Apache License 2.0
This repo contains the Spacemesh protocol specifications and related documentation
Home Page: http://protocol.spacemesh.io/
License: Apache License 2.0
Do we want to update the terminology throughout these docs? CC @avive
While reading the white paper of spacemesh, I've raised a few questions, hope here's the right place to find the answer!
The abstract of "Tortoise and Hares Consensus" thesis says:
We propose Meshcash, a new framework for cryptocurrency protocols that combines a
novel, proof-of-work based, permissionless byzantine consensus protocol (the tortoise) that
guarantees eventual consensus and irreversibility, with a possibly-faulty but quick consensus
protocol (the hare).
What exactly does the faulty mean here? Does it mean that the hare protocol can't reach consensus(liveness) or the consensus is wrong(safeness)?
In spacemesh's paper, the hare protocol is iterative, and it's not clear how the tortoise protocol could help when the hare protocol is stuck in iterations.
https://docs.google.com/document/d/1fyASTE83bcSyLecyKOFS4CNeMhmjtwWxu-_ymLI2S2M/edit
Should replace https://github.com/spacemeshos/go-spacemesh/wiki/p2p2 and https://github.com/spacemeshos/go-spacemesh/wiki/P2P-Architecture
Yosher shared these newer notes, check whether they contain anything relevant for this doc:
https://github.com/spacemeshos/protocol/blob/master/mining/04-nipost.md should be updated to explain exactly how a NIPoST is validated.
NIPoST may be thought of as the glue that chains multiple, sequential proofs together, or alternatively as a second order or meta-proof which wraps or contains, as constituent parts, a Proof of Elapsed Time and multiple Proofs of Space-time
Add high-level flow for each component so tests may be designed from this flow. e.g.
CREATE ANIMATION INSTEAD OF AN IMAGE; consider improving image by numbering the arrows 1, 2, 3
I can't remember where we left this off, @antonlerner is this something you still intend to work on?
We need to explain how the hare protocol is different than Hotstuff and why we chose it over Hotstuff. This is a common question by protocol researchers / dev looking at Spacemesh protocol for the first time.
See #28
Here is a detailed output of all the buffers during a transaction. This might be helpful for someone who wants to implement transactions in a wallet
Restarted application in 425ms.
flutter: >any bip39 library
flutter: >generate mnemonic
flutter: mnemonic: bus object report ask kind torch rule swamp observe crowd worry say
flutter: >get seed of mnemonic
flutter: Seed from mnemonic: [145, 185, 165, 25, 157, 154, 229, 127, 168, 252, 138, 212, 128, 138, 235, 13, 133, 145, 213, 72, 57, 162, 43, 123, 6, 32, 240, 28, 84, 138, 195, 17]
flutter: >Ed25519Lib.newDerivedKeyFromSeed(Uint8List.fromList(seed),Uint8List.fromList([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),Uint8List.fromList(utf8.encode('Spacemesh blockmesh')));
flutter: privateKey bytes: 2e45f3bf151774762d01947ab550bec31ac9f852b7e70eebc9aee94ef3ce9fcdbedd6066b5fa9725f53e27381fc61195318e92d223521607b3e93f4ba8588c10
flutter: >Ed25519Lib.sign2(privateKey, dummyMessage);
flutter: derive public key from dummy message and signature: [200, 242, 219, 170, 34, 249, 111, 156, 243, 22, 106, 225, 76, 144, 179, 113, 247, 58, 114, 37, 173, 226, 115, 145, 84, 154, 159, 33, 209, 5, 91, 118, 141, 97, 15, 210, 69, 125, 103, 23, 143, 60, 232, 111, 186, 173, 127, 166, 134, 161, 192, 80, 248, 133, 169, 195, 129, 1, 36, 206, 252, 93, 110, 12]
flutter: >Ed25519Lib.extractPublicKey(dummyMessage, signature!);
flutter: publicKey bytes: bedd6066b5fa9725f53e27381fc61195318e92d223521607b3e93f4ba8588c10
flutter: >hex.encode(publicKeyList).substring(24)
flutter: address derived from publickey: 1fc61195318e92d223521607b3e93f4ba8588c10
flutter: create GlobalStateServiceClient grpc client
flutter: accountQueryId = new AccountId(address: privateKey.sublist(24));
flutter: accountQueryFilter = new AccountDataFilter(accountId: accountQueryId,accountDataFlags: AccountDataFlag.ACCOUNT_DATA_FLAG_ACCOUNT.value);
flutter: accountQuery = new AccountDataQueryRequest(filter: accountQueryFilter, maxResults: 1);
flutter: AccountDataQueryResponse accountQueryResponse = await accountClient.accountDataQuery(accountQuery);
flutter: accountQueryResponse: [accountWrapper: {
accountId: {
address: [31, 198, 17, 149, 49, 142, 146, 210, 35, 82, 22, 7, 179, 233, 63, 75, 168, 88, 140, 16]
}
stateCurrent: {
counter: 4
balance: {
value: 999999999956
}
}
stateProjected: {
counter: 12
balance: {
value: 999999999861
}
}
}
]
flutter: accountNonce = accountQueryResponse.accountItem.first.accountWrapper.stateProjected.counter.toInt()
flutter: create TransactionServiceClient grpc client
flutter: recipient size: 20
flutter: >InnerTx(_accountNonce, _address, _gasLimit, _fee, _amount)
flutter: create inner transaction : [0, 0, 0, 0, 0, 0, 0, 12, 198, 76, 190, 17, 82, 89, 180, 221, 149, 2, 230, 31, 2, 218, 203, 212, 253, 91, 15, 76, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 11]
flutter: inner transaction size: 52
flutter: >Ed25519Lib.sign2(privateKey, Uint8List.fromList(unsignedOutStream));
flutter: create transaction signature: [142, 87, 68, 197, 219, 109, 61, 214, 238, 46, 237, 2, 230, 52, 96, 158, 79, 139, 90, 245, 196, 84, 132, 26, 221, 4, 95, 50, 251, 167, 62, 38, 237, 195, 125, 237, 225, 75, 67, 69, 212, 77, 161, 118, 127, 175, 105, 210, 95, 218, 11, 91, 36, 46, 174, 122, 120, 93, 175, 254, 217, 185, 123, 9]
flutter: signature size: 64
flutter: origin length: 20
flutter: origin: [179, 233, 63, 75, 168, 88, 140, 16]
flutter: >_hashTxId is sha256 over _innerTransactionStream + _signature + _origin
flutter: >OuterTx(_innerTransactionStream, _signature, _origin, _hashTxId)
flutter: create outer transaction packet: [0, 0, 0, 0, 0, 0, 0, 12, 198, 76, 190, 17, 82, 89, 180, 221, 149, 2, 230, 31, 2, 218, 203, 212, 253, 91, 15, 76, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 11, 142, 87, 68, 197, 219, 109, 61, 214, 238, 46, 237, 2, 230, 52, 96, 158, 79, 139, 90, 245, 196, 84, 132, 26, 221, 4, 95, 50, 251, 167, 62, 38, 237, 195, 125, 237, 225, 75, 67, 69, 212, 77, 161, 118, 127, 175, 105, 210, 95, 218, 11, 91, 36, 46, 174, 122, 120, 93, 175, 254, 217, 185, 123, 9, 201, 174, 233, 78, 243, 206, 159, 205, 190, 221, 96, 102, 181, 250, 151, 37, 245, 62, 39, 56, 31, 198, 17, 149, 49, 142, 146, 210, 35, 82, 22, 7, 179, 233, 63, 75, 168, 88, 140, 16, 242, 92, 107, 193, 117, 116, 142, 112, 2, 44, 58, 127, 165, 226, 203, 165, 32, 93, 143, 172, 215, 222, 255, 36, 187, 80, 248, 223, 214, 70, 177, 163]
flutter: outer transaction packet size: 188
flutter: sent grpc transaction request
It's pretty spare right now. It should probably include deep links into the various content sections.
See #24
We'll want to be able to break these out in more detail than we can do inline in existing docs, see e.g. #5 (comment)
Relative links, e.g., the ones in mining/01-overview.md
, which point to other md files in the same directory, are broken in the http://protocol.spacemesh.io/#/mining/01-overview doc. Turn these into absolute links.
This belongs in https://github.com/spacemeshos/protocol/blob/master/consensus/02-deepdive.md#other-proof-of-space-based-protocols. I asked about this on slack but didn't get any response. We still have some homework to do here.
CREATE VERTICAL ANIMATION TO ILLUSTRATE THE NIPOSTS CHAINING: initialization -> poet -> execution -> poet -> execution -> poet -> ….
This is less critical because it only happens once per network but it should be documented
describe the finalised sync protocol in the project wiki
Our model assumes honest parties have synchronized clocks.
Clock synchronization among nodes in a distributed system is, as far as I understand, literally impossible — edit: if the system should be available and/or consistent. Am I mistaken? How can this invariant be confirmed?
Nodes in Spacemesh have multiple personality disorder :) They each use multiple, distinct identities. Per @noamnelke (#22 (comment)):
We use 3 distinct keypairs:
For P2P auth - ephemeral, changes every time the node restarts, only used to encrypt communication with peers.
For mining - used for signing blocks, ATXs and hare messages, as well as generate eligibility proofs. We actually have two keypairs for mining using different signing schemes (ED vs. BLS) used for different purposes, but that's the topic for another discussion.
For wallets - used for signing transactions.
Keeping the p2p keypair separate from the others is a privacy enabling feature, since p2p IDs are considered not private - anyone on the network can tell the IP address of any p2p ID. While traffic analysis can help associate the two IDs, there are steps one can take to regain some privacy and we want to add more privacy enabling features in the future (e.g. dandelion).As an aside, we keep the wallet and node keypairs distinct by default because the security model of these two uses is very different. Stealing one's mining private key without their PoST data can enable disqualifying them in the worst case. With the PoST data, which is much harder to steal since it's huge, it can allow one to steal future revenue, but not covertly.
Stealing one's wallet private key, as you surely understand, allows taking away all of their savings. So while a miner's private key must be kept "hot", the wallet private key can and should be kept in cold storage.
I added the relevant P2P info here to the P2P doc. Consider creating a new doc to talk more about identity and the decision to use distinct keypairs for different purposes.
Following on our conversation in this thread:
barakshani
we get redundancy, but how much would depend on the number of transactions waiting in the mempool. Given the number of (average) blocks in a layer and the limit of transaction per block (so basically given the limit of transactions in a layer), there is some number of transactions in the mempool for which we don't expect to get duplications at all (if the limit of transactions in a layer is n, then once there are roughly n^2 transactions in the mempool, we expect no duplications)
@barakshani what happens when there is < n transactions in the mempool? Don't all of the blocks in a layer basically contain the same set of transactions then? Nothing would break, but it just seems like a lot of redundant data storage doesn't it?
As discussed yesterday on call with @ilans, apparently the P2P layer implements some sort of priority queue on outgoing gossip messages - since some, e.g., Hare messages, are more time-sensitive. Understand and document this.
Based on spacemeshos/SMIPS#13. Once the design for this is finalized, and maybe implemented, document it here.
hare-wakeup-delta
parameter, right? Doesn't this mean that it punishes blocks that arrive just a little bit late - i.e., blocks that could've arrived later if there were no Hare and were only a Tortoise?expected_leaders
flag do?getLayerFromNeighbors
for an older layer, right? Only the top/current layer? And everything else happens recursivelyContinuing the conversation from #22 (comment)...
@noamnelke pointed out:
While I agree that it would be nice if it wasn't possible to discover the entire network, unfortunately, this is not the case. If one wants to, they can simply keep running the discovery protocol and eventually be aware of all the nodes. Moreover, even a benevolent node is likely to be aware of most of the network pretty fast even without making special effort.
Which reminds me a lot of this attack against MimbleWimble/Grin.
How concerned are we about this? Is there anything we can do about this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.