SlideShare a Scribd company logo
1 of 37
Download to read offline
Cosmos-SDK
Talkshop
Before we begin...
Talkshop: Talk + Workshop
(Interactive presentation)
Download the tutorial
github.com/cosmos/sdk-application-tutorial
goes in $GO_PATH/src/github.com/cosmos/
make get_tools && make get_vendor_deps && make install
Welcome!
Let’s use the Cosmos-SDK
To make a
Blockchain
Replicated State Machine
Hi, I’m Jack ✌
Replicated State Machine
What is the initial state?
What are the possible state transitions?
Is it Byzantine Fault Tolerant?
Cosmos Developer Kit
Golang toolset for building Replicated State Machines
Ruby-on-Rails for Blockchain
Focus on the Application
Proof-of-Stake 🍃 is better than Proof-of-Work ☠🔥
Tendermint for Consensus & Networking
Our Application!
Distributed Name Service
No one should be able to limit access to a public utility
Distribute the access and responsibility
● Ethereum Name Service
● Handshake
● Namecoin/Blockstack
Our Application!
● github.com/cosmos/sdk-application-tutorial
● Download the tutorial to follow along with code
● At the end I’ll spin up a node and give everyone money
● You can create and buy names from each other
The SDK is a Modular Framework
● Aggregates a collection of interoperable modules
● Each Module has its own Message/Transaction processor
● The SDK routes each message to the respective module
Modules in this Tutorial
● Auth
○ Access Control List (ACL) with Asymmetric Encryption
● Bank
○ Money Money Money
● NameService
○ Whois???
Modules NOT in this Tutorial
● Staking
○ Used for updating the set of validators
○ We use a fixed set from genesis
○ Private => Permissioned => Public
● Governance
○ Let’s Vote!
Modules are States & Messages
Modules: State
● All state goes in one store called multistore
● Contains multiple key/value stores called KVStores
● Our State
○ Accounts (auth)
○ Balances (bank)
○ Domain Names (nameservice)
Domain Names: nameStore
● Name => Value
○ What does the name resolve to (the zonefile)?
● Name => Owner
○ Who owns the name?
● Name => Price
○ How much to buy it?
Modules: Messages
● Messages Trigger State Transitions
● The Module Routes the Messages to Handlers
● The Handlers Hand them to Keepers
● The Keepers update the State
Domain Names: Messages
● MsgSetName
○ This message allows an owner to set the value of a name
● MsgBuyName
○ This message allows anyone to buy a name for some price
General Flow
● A Transaction contains a Message
● Tendermint nodes receive Transactions in Blocks
● They’re passed to the application via ABCI
○ Application Blockchain Interface
○ Socket Protocol between Tendermint and the application
● Decoded as Messages by baseapp & routed to correct Module
● Each Module has Handlers that decides what to do with them
● Each Handler calls Keepers to update the State
Let’s begin in ./app.go
● Imports
○ Log - for logs
○ Auth - for accounts and signing
○ Dbm - tendermint database
○ Codec - serialization
○ Baseapp - boilerplate
● Makes a new Type called nameservice
○ That’s our app!
Let’s begin in ./app.go
● Imports
○ Log - for logs
○ Auth - for accounts and signing
○ Dbm - tendermint database
○ Codec - serialization
○ Bam - Baseapp boilerplate
● Makes a new Type called nameservice
○ That’s our app!
Our nameservice module
● All modules go in the directory called ./x/
● Our module goes in the directory called ./x/nameservice/
● Inside ./x/nameservice/ we’ll have:
○ Handler.go
○ Keeper.go
○ Querier.go
○ Msgs.go
○ Codec.go
○ Client/ => for REST & CLI
● Keepers manage the state
○ Like reducers/redux or mutations/vuex
● Handlers call the Keepers
○ Like actions in redux/vuex
The Keeper
● nameStoreKey
○ map[name]value - like a Zonefile w traditional DNS
● ownerStoreKey
○ map[sdk_address]name - who owns what
● priceStoreKey
○ map[name]price - how much a name costs
Our Keeper has 3 New Keys
● Getters
○ ResolveName
○ HasOwner
○ GetOwner
○ GetPrice
● Setters
○ SetName
○ SetOwner
○ SetPrice
Our Keeper has Getters & Setters
Our Keeper has Getters & Setters
Msgs & Handlers
● Msgs trigger Handlers
○ Like user initiated events
● Handlers call the Keepers
○ Like actions in redux/vuex
● Keepers manage the state
○ Like reducers/redux or mutations/vuex
Msgs go in ./x/nameservice/msgs.go
Two Msg Types Needed For Our App
● MsgSetName
○ Owners can set the name
● MsgBuyName
○ Names can be bought
MsgSetName
● Set all the Interfaces
● Example: ValidateBasic
handleMsgSetName
● Goes in ./x/nameservice/handler.go
● Utilizes the Keeper we made earlier
Queriers
● Queriers : Getters
● Handlers : Setters
● Goes inside ./x/nameservice/querier.go
● Uses the Keeper to access the KVStore
Our Queriers
● Resolve
○ Accepts name returns value
● Whois
○ Accepts name returns value, price, owner
Our Queriers: Whois
Codec
● Register new msg types for serialization (not whois?)
● Amino is an extension of protobuf
● Goes in ./x/nameservice/codec.go
Building Clients!
● From the Command Line
○ Utilizes the cobra library
○ Goes in ./x/nameservice/client/cli/query.go
○ Goes in ./x/nameservice/client/cli/tx.go
● From a REST server
○ Goes in ./x/nameservice/client/rest/rest.go
● Export both from Module Client
○ Goes in ./x/nameservice/client/module_client.go
Pull it all back into app.go
● Import and Initialize all our new pieces
● AddRoute for Handlers and Queriers
● Register the Codecs
● InitChainer for initial application state
○ Takes a genesis.json file that can be generated by the CLI
○ This is where I’ll add everyone’s public key and some
balance of token for buying names $ )
Build our Binaries!
● Wrap our app with commands we can use
● Wrap our client with commands we can use
● ./cmd/nsd/main.go
○ Name Service Daemon runs our node
● ./cmd/nscli/main.go
○ Name Service CLI
One last step
● Makefile
○ Installs and builds
● Gopkg
○ keeps our versions constrained
● Build!
○ dep ensure -update -v
○ make install
Claim Your Name!
Go to talkshop.name/

More Related Content

What's hot

Distributed transactions in SOA and Microservices
Distributed transactions in SOA and MicroservicesDistributed transactions in SOA and Microservices
Distributed transactions in SOA and MicroservicesConstantine Slisenka
 
Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?Frederic Descamps
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchainBellaj Badr
 
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Natan Silnitsky
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contractsssusercc3bf81
 
Grokking Techtalk #37: Software design and refactoring
 Grokking Techtalk #37: Software design and refactoring Grokking Techtalk #37: Software design and refactoring
Grokking Techtalk #37: Software design and refactoringGrokking VN
 
CNIT 141: 8. Authenticated Encryption
CNIT 141: 8. Authenticated EncryptionCNIT 141: 8. Authenticated Encryption
CNIT 141: 8. Authenticated EncryptionSam Bowne
 
Testing an onion architecture - done right
Testing an onion architecture - done rightTesting an onion architecture - done right
Testing an onion architecture - done rightMichel Schudel
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQLMydbops
 
Attacks on Smart Contracts
Attacks on Smart ContractsAttacks on Smart Contracts
Attacks on Smart ContractsMarcin Majchrzak
 
Introduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting LanguageIntroduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting LanguageJeff Flowers
 
Build 2017 SQL Server in Dev Ops
Build 2017 SQL Server in Dev OpsBuild 2017 SQL Server in Dev Ops
Build 2017 SQL Server in Dev OpsTravis Wright
 
Blockchain testing strategy
Blockchain testing strategyBlockchain testing strategy
Blockchain testing strategyrajni singh
 
Blockchain ecosystem and evolution
Blockchain ecosystem and evolutionBlockchain ecosystem and evolution
Blockchain ecosystem and evolutionChandra Sekhar AKNR
 

What's hot (20)

Crypto wallets
Crypto walletsCrypto wallets
Crypto wallets
 
Distributed transactions in SOA and Microservices
Distributed transactions in SOA and MicroservicesDistributed transactions in SOA and Microservices
Distributed transactions in SOA and Microservices
 
Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?Galera Replication Demystified: How Does It Work?
Galera Replication Demystified: How Does It Work?
 
Implementing ossec
Implementing ossecImplementing ossec
Implementing ossec
 
Paxos
PaxosPaxos
Paxos
 
Security in the blockchain
Security in the blockchainSecurity in the blockchain
Security in the blockchain
 
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
Workflow Engines & Event Streaming Brokers - Can they work together? [Current...
 
Algorand Smart Contracts
Algorand Smart ContractsAlgorand Smart Contracts
Algorand Smart Contracts
 
Grokking Techtalk #37: Software design and refactoring
 Grokking Techtalk #37: Software design and refactoring Grokking Techtalk #37: Software design and refactoring
Grokking Techtalk #37: Software design and refactoring
 
CNIT 141: 8. Authenticated Encryption
CNIT 141: 8. Authenticated EncryptionCNIT 141: 8. Authenticated Encryption
CNIT 141: 8. Authenticated Encryption
 
Testing an onion architecture - done right
Testing an onion architecture - done rightTesting an onion architecture - done right
Testing an onion architecture - done right
 
ch-05.ppt
ch-05.pptch-05.ppt
ch-05.ppt
 
ProxySQL for MySQL
ProxySQL for MySQLProxySQL for MySQL
ProxySQL for MySQL
 
Spring JMS
Spring JMSSpring JMS
Spring JMS
 
Attacks on Smart Contracts
Attacks on Smart ContractsAttacks on Smart Contracts
Attacks on Smart Contracts
 
Introduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting LanguageIntroduction to Bitcoin's Scripting Language
Introduction to Bitcoin's Scripting Language
 
Build 2017 SQL Server in Dev Ops
Build 2017 SQL Server in Dev OpsBuild 2017 SQL Server in Dev Ops
Build 2017 SQL Server in Dev Ops
 
Recon
ReconRecon
Recon
 
Blockchain testing strategy
Blockchain testing strategyBlockchain testing strategy
Blockchain testing strategy
 
Blockchain ecosystem and evolution
Blockchain ecosystem and evolutionBlockchain ecosystem and evolution
Blockchain ecosystem and evolution
 

Similar to Cosmos SDK Workshop: How to Build a Blockchain from Scratch

Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at DecisivTeleport
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systemsMax Małecki
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liujbossug
 
Future of Cloud Computing with Containers
Future of Cloud Computing with ContainersFuture of Cloud Computing with Containers
Future of Cloud Computing with ContainersLakmal Warusawithana
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopVelocidex Enterprises
 
Introduction to Jhipster
Introduction to JhipsterIntroduction to Jhipster
Introduction to JhipsterKnoldus Inc.
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Velocidex Enterprises
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 
Microservices development at scale
Microservices development at scaleMicroservices development at scale
Microservices development at scaleVishal Banthia
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAndrei Sebastian Cîmpean
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in ContainerizationRyan Hunter
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker ClusteringRoyee Tager
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providersHotstar
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and HerokuTapio Rautonen
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUPRonald Hsu
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyJérémy Wimsingues
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarApplitools
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendVlad Fedosov
 

Similar to Cosmos SDK Workshop: How to Build a Blockchain from Scratch (20)

Secure Developer Access at Decisiv
Secure Developer Access at DecisivSecure Developer Access at Decisiv
Secure Developer Access at Decisiv
 
Chaincode Use Cases
Chaincode Use Cases Chaincode Use Cases
Chaincode Use Cases
 
Idempotency of commands in distributed systems
Idempotency of commands in distributed systemsIdempotency of commands in distributed systems
Idempotency of commands in distributed systems
 
Guvnor presentation jervis liu
Guvnor presentation jervis liuGuvnor presentation jervis liu
Guvnor presentation jervis liu
 
Future of Cloud Computing with Containers
Future of Cloud Computing with ContainersFuture of Cloud Computing with Containers
Future of Cloud Computing with Containers
 
Crikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor WorkshopCrikeycon 2019 Velociraptor Workshop
Crikeycon 2019 Velociraptor Workshop
 
Introduction to Jhipster
Introduction to JhipsterIntroduction to Jhipster
Introduction to Jhipster
 
Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3Digital Forensics and Incident Response in The Cloud Part 3
Digital Forensics and Incident Response in The Cloud Part 3
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Microservices development at scale
Microservices development at scaleMicroservices development at scale
Microservices development at scale
 
An approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSocketsAn approach to responsive, realtime with Backbone.js and WebSockets
An approach to responsive, realtime with Backbone.js and WebSockets
 
Truemotion Adventures in Containerization
Truemotion Adventures in ContainerizationTruemotion Adventures in Containerization
Truemotion Adventures in Containerization
 
Swarm: Native Docker Clustering
Swarm: Native Docker ClusteringSwarm: Native Docker Clustering
Swarm: Native Docker Clustering
 
WebSDK - Switching between service providers
WebSDK - Switching between service providersWebSDK - Switching between service providers
WebSDK - Switching between service providers
 
Introduction to PaaS and Heroku
Introduction to PaaS and HerokuIntroduction to PaaS and Heroku
Introduction to PaaS and Heroku
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP202107 - Orion introduction - COSCUP
202107 - Orion introduction - COSCUP
 
Heroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success storyHeroku to Kubernetes & Gihub to Gitlab success story
Heroku to Kubernetes & Gihub to Gitlab success story
 
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil TayarDocker and Your Path to a Better Staging Environment - webinar by Gil Tayar
Docker and Your Path to a Better Staging Environment - webinar by Gil Tayar
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 

More from Tendermint Inc

Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedVision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedTendermint Inc
 
Many Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemMany Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemTendermint Inc
 
Open Finance & the Decentralization Movement
Open Finance & the Decentralization MovementOpen Finance & the Decentralization Movement
Open Finance & the Decentralization MovementTendermint Inc
 
Introduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangIntroduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangTendermint Inc
 
Interblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityInterblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityTendermint Inc
 
A Brief History of Distributed State
A Brief History of Distributed StateA Brief History of Distributed State
A Brief History of Distributed StateTendermint Inc
 
Code Run of the Cosmos SDK
Code Run of the Cosmos SDKCode Run of the Cosmos SDK
Code Run of the Cosmos SDKTendermint Inc
 
Intro to the Cosmos Network
Intro to the Cosmos NetworkIntro to the Cosmos Network
Intro to the Cosmos NetworkTendermint Inc
 
Four Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingFour Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingTendermint Inc
 
Cosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionCosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionTendermint Inc
 

More from Tendermint Inc (10)

Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango UnchainedVision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
Vision of Rearchitecting the Blockchain Ecosystem by Chjango Unchained
 
Many Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One EcosystemMany Chains, Many Tokens, One Ecosystem
Many Chains, Many Tokens, One Ecosystem
 
Open Finance & the Decentralization Movement
Open Finance & the Decentralization MovementOpen Finance & the Decentralization Movement
Open Finance & the Decentralization Movement
 
Introduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with GolangIntroduction to Blockchain & Building the 3rd Generation with Golang
Introduction to Blockchain & Building the 3rd Generation with Golang
 
Interblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain InteroperabilityInterblockchain Communication for Blockchain Interoperability
Interblockchain Communication for Blockchain Interoperability
 
A Brief History of Distributed State
A Brief History of Distributed StateA Brief History of Distributed State
A Brief History of Distributed State
 
Code Run of the Cosmos SDK
Code Run of the Cosmos SDKCode Run of the Cosmos SDK
Code Run of the Cosmos SDK
 
Intro to the Cosmos Network
Intro to the Cosmos NetworkIntro to the Cosmos Network
Intro to the Cosmos Network
 
Four Dimensional Blockchain Scaling
Four Dimensional Blockchain ScalingFour Dimensional Blockchain Scaling
Four Dimensional Blockchain Scaling
 
Cosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An IntroductionCosmos Proof-of-Stake: An Introduction
Cosmos Proof-of-Stake: An Introduction
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

Cosmos SDK Workshop: How to Build a Blockchain from Scratch

  • 2. Before we begin... Talkshop: Talk + Workshop (Interactive presentation) Download the tutorial github.com/cosmos/sdk-application-tutorial goes in $GO_PATH/src/github.com/cosmos/ make get_tools && make get_vendor_deps && make install
  • 3. Welcome! Let’s use the Cosmos-SDK To make a Blockchain Replicated State Machine Hi, I’m Jack ✌
  • 4. Replicated State Machine What is the initial state? What are the possible state transitions? Is it Byzantine Fault Tolerant?
  • 5. Cosmos Developer Kit Golang toolset for building Replicated State Machines Ruby-on-Rails for Blockchain Focus on the Application Proof-of-Stake 🍃 is better than Proof-of-Work ☠🔥 Tendermint for Consensus & Networking
  • 6. Our Application! Distributed Name Service No one should be able to limit access to a public utility Distribute the access and responsibility ● Ethereum Name Service ● Handshake ● Namecoin/Blockstack
  • 7. Our Application! ● github.com/cosmos/sdk-application-tutorial ● Download the tutorial to follow along with code ● At the end I’ll spin up a node and give everyone money ● You can create and buy names from each other
  • 8. The SDK is a Modular Framework ● Aggregates a collection of interoperable modules ● Each Module has its own Message/Transaction processor ● The SDK routes each message to the respective module
  • 9. Modules in this Tutorial ● Auth ○ Access Control List (ACL) with Asymmetric Encryption ● Bank ○ Money Money Money ● NameService ○ Whois???
  • 10. Modules NOT in this Tutorial ● Staking ○ Used for updating the set of validators ○ We use a fixed set from genesis ○ Private => Permissioned => Public ● Governance ○ Let’s Vote!
  • 11. Modules are States & Messages
  • 12. Modules: State ● All state goes in one store called multistore ● Contains multiple key/value stores called KVStores ● Our State ○ Accounts (auth) ○ Balances (bank) ○ Domain Names (nameservice)
  • 13. Domain Names: nameStore ● Name => Value ○ What does the name resolve to (the zonefile)? ● Name => Owner ○ Who owns the name? ● Name => Price ○ How much to buy it?
  • 14. Modules: Messages ● Messages Trigger State Transitions ● The Module Routes the Messages to Handlers ● The Handlers Hand them to Keepers ● The Keepers update the State
  • 15. Domain Names: Messages ● MsgSetName ○ This message allows an owner to set the value of a name ● MsgBuyName ○ This message allows anyone to buy a name for some price
  • 16. General Flow ● A Transaction contains a Message ● Tendermint nodes receive Transactions in Blocks ● They’re passed to the application via ABCI ○ Application Blockchain Interface ○ Socket Protocol between Tendermint and the application ● Decoded as Messages by baseapp & routed to correct Module ● Each Module has Handlers that decides what to do with them ● Each Handler calls Keepers to update the State
  • 17. Let’s begin in ./app.go ● Imports ○ Log - for logs ○ Auth - for accounts and signing ○ Dbm - tendermint database ○ Codec - serialization ○ Baseapp - boilerplate ● Makes a new Type called nameservice ○ That’s our app!
  • 18. Let’s begin in ./app.go ● Imports ○ Log - for logs ○ Auth - for accounts and signing ○ Dbm - tendermint database ○ Codec - serialization ○ Bam - Baseapp boilerplate ● Makes a new Type called nameservice ○ That’s our app!
  • 19. Our nameservice module ● All modules go in the directory called ./x/ ● Our module goes in the directory called ./x/nameservice/ ● Inside ./x/nameservice/ we’ll have: ○ Handler.go ○ Keeper.go ○ Querier.go ○ Msgs.go ○ Codec.go ○ Client/ => for REST & CLI
  • 20. ● Keepers manage the state ○ Like reducers/redux or mutations/vuex ● Handlers call the Keepers ○ Like actions in redux/vuex The Keeper
  • 21. ● nameStoreKey ○ map[name]value - like a Zonefile w traditional DNS ● ownerStoreKey ○ map[sdk_address]name - who owns what ● priceStoreKey ○ map[name]price - how much a name costs Our Keeper has 3 New Keys
  • 22. ● Getters ○ ResolveName ○ HasOwner ○ GetOwner ○ GetPrice ● Setters ○ SetName ○ SetOwner ○ SetPrice Our Keeper has Getters & Setters
  • 23. Our Keeper has Getters & Setters
  • 24. Msgs & Handlers ● Msgs trigger Handlers ○ Like user initiated events ● Handlers call the Keepers ○ Like actions in redux/vuex ● Keepers manage the state ○ Like reducers/redux or mutations/vuex
  • 25. Msgs go in ./x/nameservice/msgs.go
  • 26. Two Msg Types Needed For Our App ● MsgSetName ○ Owners can set the name ● MsgBuyName ○ Names can be bought
  • 27. MsgSetName ● Set all the Interfaces ● Example: ValidateBasic
  • 28. handleMsgSetName ● Goes in ./x/nameservice/handler.go ● Utilizes the Keeper we made earlier
  • 29. Queriers ● Queriers : Getters ● Handlers : Setters ● Goes inside ./x/nameservice/querier.go ● Uses the Keeper to access the KVStore
  • 30. Our Queriers ● Resolve ○ Accepts name returns value ● Whois ○ Accepts name returns value, price, owner
  • 32. Codec ● Register new msg types for serialization (not whois?) ● Amino is an extension of protobuf ● Goes in ./x/nameservice/codec.go
  • 33. Building Clients! ● From the Command Line ○ Utilizes the cobra library ○ Goes in ./x/nameservice/client/cli/query.go ○ Goes in ./x/nameservice/client/cli/tx.go ● From a REST server ○ Goes in ./x/nameservice/client/rest/rest.go ● Export both from Module Client ○ Goes in ./x/nameservice/client/module_client.go
  • 34. Pull it all back into app.go ● Import and Initialize all our new pieces ● AddRoute for Handlers and Queriers ● Register the Codecs ● InitChainer for initial application state ○ Takes a genesis.json file that can be generated by the CLI ○ This is where I’ll add everyone’s public key and some balance of token for buying names $ )
  • 35. Build our Binaries! ● Wrap our app with commands we can use ● Wrap our client with commands we can use ● ./cmd/nsd/main.go ○ Name Service Daemon runs our node ● ./cmd/nscli/main.go ○ Name Service CLI
  • 36. One last step ● Makefile ○ Installs and builds ● Gopkg ○ keeps our versions constrained ● Build! ○ dep ensure -update -v ○ make install
  • 37. Claim Your Name! Go to talkshop.name/