Polkadot and Cosmos are both protocols that provide an interface for different state machines tocommunicate with each other. Both protocols are predicated on the thesis that the future will havemultiple blockchains that need to interoperate with each other rather than individual blockchainsexisting in isolation.
Model
Polkadot uses a sharded model where each shard in the protocol has an abstract state transitionfunction (STF). Polkadot uses WebAssembly (Wasm) as a "meta-protocol". A shard's STF can be abstractas long as the validators on Polkadot can execute it within a Wasm environment.
The shards of Polkadot are called "parachains". Every time a parachain wantsto make a state transition, it submits a block (batch of state transitions) along with a state proofthat Polkadot validators can independently verify. These blocks are finalized for the parachainswhen they are finalized by Polkadot's Relay Chain, the main chain of the system. As such, allparachains share state with the entire system, meaning that a chain re-organization of a singleparachain would require a re-organization of all parachains and the Relay Chain.
Cosmos employs horizontal scalability usingapp-chains. The Cosmos Network consists of100+ IBC connected chains, including the Cosmos Hub, Osmosis, Celestia, dYdX v4 chain, Injective,etc. Each chain is responsible for securing the chain with a sufficiently staked and decentralizedvalidator set. But chains also have the option to leverage shared security from the Cosmos Hub.Cosmos chains send cross-chain messages using the Inter-Blockchain Communication protocol. As chainsdo not share state, a re-organization of one chain would not re-organize other chains, meaning eachmessage is trust-bound by the recipient's trust in the security of the sender.
Architecture
Polkadot
Polkadot has a Relay Chain acting as the main chain of the system. All validators in Polkadot are onthe Relay Chain. Parachains have collators, who construct and propose parachain blocks tovalidators. Collators don't have any security responsibilities, and thus do not require a robustincentive system. Collators can submit a single parachain block for every Relay Chain block every 6seconds. Once a parachain submits a block, validators perform a series of availability and validitychecks before committing it to the final chain.
Parachain slots are limited, and thus parachain candidates participate in an auction to reserve aslot for up to two years. For chains that do not have the funding for a parachain slot or thenecessity to execute with a six-second block time, Polkadot also hason-demand parachains that execute on a pay-as-you-gobasis, only paying to execute a block when they need to.
In order to interact with chains that want to use their own finalization process (e.g. Bitcoin),Polkadot has bridge parachains that offer two-way compatibility.
Cosmos
Cosmos is a network of blockchains built using CometBFT as the consensusengine, Cosmos SDK as the VM, and IBCwhich allows chains to interoperate with one another.
IBC leverages light clients that can keep track of the consensus of a counterparty chain. Forexample, when chains A and B want to talk to one another, chain A uses its light client of B toverify messages sent from chain B, and vice versa. IBC iscurrently live on Polkadot and Kusama. Workis ongoing to implement IBC to Ethereum and it's layer 2s.
Consensus
Polkadot uses a hybrid consensus protocol with two sub-protocols: BABE andGRANDPA. BABE (Blind Assignment for Blockchain Extension) uses a verifiable random function (VRF) toassign slots to validators and a fallback round-robin pattern to guarantee that each slot has anauthor. GRANDPA (GHOST-based Recursive Ancestor Deriving Prefix Agreement) votes on chains, ratherthan individual blocks. Together, BABE can author candidate blocks to extend the finalized chain andGRANDPA can finalize them in batches (up to millions of blocks at a time).
This isolation of tasks provides several benefits. First, it represents a reduction in transportcomplexity for both block production and finalization. BABE has linear complexity, making it easy toscale to thousands of block producers with low networking overhead. GRANDPA has quadraticcomplexity, but has an advantage in terms of the latency. It is capable of finalizing multipleblocks in one batch.
Second, having the capacity to extend the chain with unfinalized blocks allows for liveness of thenetwork and the validators to perform extensive availability and validity checks to ensure that noinvalid state transitions make their way into the final chain.
Cosmos chains use Tendermint consensus, a round-robin protocol that provides instant finality. Blockproduction and finalization are on the same path of the algorithm, meaning it produces and finalizesone block at a time. Because it is a PBFT-based algorithm (like GRANDPA), it has quadraticcomplexity, designed to finalize one block at a time.
Staking Mechanics
Polkadot uses Nominated Proof of Stake (NPoS) to select validators using thesequential Phragmén algorithm. The validator set size is set by governance(1_000 validators planned) and stakers who do not want to run validator infrastructure can nominateup to 16 validators. Phragmén's algorithm selects the optimal allocation of stake, where optimal isbased on having the most evenly staked set.
All validators in Polkadot have the same weight in the consensus protocols. That is, to reachgreater than 2/3 of support for a chain, more than 2/3 of the validators must commit to it, ratherthan 2/3 of the stake. Likewise, validator rewards are tied to their activity, primarily blockproduction and finality justifications, not their amount of stake. This creates an incentive tonominate validators with lower stakes, as they will earn higher returns on their staked tokens.
The Cosmos Hub uses Bonded Proof of Stake (a variant of Delegated PoS) to elect validators. Stakersmust bond funds and submit a delegate transaction for each validator they would like to delegate towith the number of tokens to delegate. The Cosmos Hub plans to support up to 300 validators.
Consensus voting and rewards are both stake-based in Cosmos. In the case of consensus voting, morethan 2/3 of the stake must commit, rather than 2/3 of the validators. Likewise, a validator with10% of the total stake will earn 10% of the rewards.
Finally, in Cosmos, if a staker does not vote in a governance referendum, the validators assumetheir voting power. Because of this, many validators in Cosmos have zero commission in order toacquire more control over the protocol. In Polkadot, governance and staking are completely disjoint;nominating a validator does not assign any governance voting rights to the validator.
Message Passing
Polkadot uses Cross-Consensus Message Passing Format (XCM) for parachains to sendarbitrary messages to each other. Parachains open connections with each other and can send messagesvia their established channels. Collators are full nodes of parachains and fullnodes of the Relay Chain, so collator nodes are a key component of message passing. Messages do notpass through the Relay Chain, only proofs of post and channel operations (open, close, etc.) go intothe Relay Chain. This enhances scalability by keeping data on the edges of the system.
In the case of a chain re-organization, messages can be rolled back to the point of there-organization based on the proofs of post in the Relay Chain. The shared state amongst parachainsmeans that messages are free from trust bounds; they all operate in the same context.
Polkadot has an additional protocol called SPREE that provides shared logic forcross-chain messages. Messages sent with SPREE carry additional guarantees about provenance andinterpretation by the receiving chain.
Cosmos uses a light client-based cross-chain protocol calledInter-Blockchain Communication (IBC) for arbitrary message-passing.In the current design, IBC chains create 1:1Connections with each other, over whichChannels can be established. IBC datapackets are sent between application modules on different chains over these channels. In the case ofIBC, as chains do not share state, receiving chains must trust the security of a message's origin.
Governance
Polkadot has OpenGov framewok with several trackss to pass proposals aspublic referenda, where the majority of tokens can always control the outcome. Referenda can containa variety of proposals, including fund allocation from an on-chainTreasury. Decisions get enacted on-chain and are binding andautonomous.
Cosmos uses coin-vote signaling to pass referenda. The actual enactment of governance decisions iscarried out via a protocol fork, much like other blockchains. All token holders can vote, however,if a delegator abstains from a vote then the validator they delegate to assume their voting power.Validators in Polkadot do not receive any voting power based on their nominators.
Upgrades
Using the Wasm meta-protocol, Polkadot can enact chain upgrades and successful proposals without ahard fork. Anything that is within the STF, the transaction queue, or off-chain workers can beupgraded without forking the chain.
As Cosmos is not based on a meta-protocol, it must enact upgrades and proposals via a normal forkingmechanism.
Development Framework
Both Cosmos and Polkadot are designed such that each chain has its STF and both provide support forsmart contracts in both Wasm and the Ethereum Virtual Machine (EVM). Polkadot provides anahead-of-time Wasm compiler as well as an interpreter (Wasmi) for execution, while Cosmos onlyexecutes smart contracts in an interpreter.
Cosmos chains can be developed using the Cosmos SDK, written in Go. The Cosmos SDK contains about 10modules (e.g. staking, governance, etc.) that can be included in a chain's STF. The SDK builds ontop of Tendermint.
The primary development framework for parachains is Substrate, written inRust. Substrate comes with FRAME, a set of about 40 modules (called "pallets") to use in a chain'sSTF. Beyond simply using the pallets, Substrate adds a further layer of abstraction that allowsdevelopers to compose FRAME's pallets by adding custom modules and configuring the parameters andinitial storage values for the chain.
Polkadot can support an STF written in any language
So long as it compiles to its meta-protocol Wasm. Likewise, it could still use the Substrate client(database, RPC, networking, etc.); it only needs to implement the primitives at the interface.
Conclusion
Polkadot was designed on the principle that scalability and interoperability require sharedvalidation logic to create a trust-free environment. As more blockchains are developed, theirsecurity must be cooperative, not competitive. Therefore, Polkadot provides the shared validationlogic and security processes across chains so that they can interact knowing that theirinterlocutors execute within the same security context.
The Cosmos network uses an Internet-like unstructured network that uses IBC to connect chains withindependent security guarantees, meaning that when data is sent from one chain to another, thereceiving chain must trust the sending chain. Thus, each blockchain in the Cosmos network has itsindependent security mechanisms. Chains also have the option to share security with the Cosmos Huband thereby leverage its economic security.