Aajtak Chain
Aajtak Chain
Aajtak Chain
SUHAS AGGARWAL
Main Strengths
Aajtak Chain is a multichain platform
interoperable with Ethereum, Bitcoin, Binance
Chain, Tron, and all major blockchains.
Deploy once to Aajtak Chain’s mainnet —
Basechain — and reach the largest user base
possible, so one can simply focus on Aajtak
development and business growth.
Enjoy having no gas fees for users, 5 second
confirmation times, and automatically get
connected to every major blockchain using any
kind of wallet.
Cool Features!!
Access the user base of multiple chains
1–3 second confirmation times
No gas fees for your users
Avoid mainnet transaction congestion
Fully compatible with MetaMask and other major Ethereum wallets
TRANSFER GATEWAY
The Transfer Gateway allows
tokens to be transferred between
Aajtak Chains and Ethereum
networks.
The Transfer Gateway consists
of four main components:
TRANSFER GATEWAY
The Transfer Gateway allows
tokens to be transferred between
AajtakChains and Ethereum
networks.
The Transfer Gateway consists
of four main components:
#Transferring a token from AajtakChain to
Ethereum
To get that same token back into their Ethereum
account the user must:
Transfer the token back to the AajtakChain
Gateway, which creates a pending withdrawal.
The pending withdrawal is picked up by the
Gateway Oracle, which signs the withdrawal,
and notifies the AajtakChain Gateway.
The AajtakChain Gateway emits an event to let
the user know they can withdraw their token
from the Mainnet Gateway to their Ethereum
account by providing the signed withdrawal
Role of oracle in transfer
gateway
Polls Ethereum
switch orc.gatewayType {
}
case TokenKind_ERC20, TokenKind_ETH, TokenKind_AajtakCoin, TokenKind_BNBAajtakToken,
TokenKind_BEP2:
if len(unclaimedToken.Amounts) == 1 {
amount = Aajtak.NewBigUInt(unclaimedToken.Amounts[0].TokenAmount.Value.Int)
}
unclaimedAmount = unclaimedAmount.Add(unclaimedAmount, amount)
}
}
return &GetUnclaimedContractTokensResponse{
Workflow illustration of pending withdrawl receipt signing from multiple
Validators and simulation of token withdrawal from Ethereum Gateway to
clear out the pending withdrawal
calculatedHash :=
client.ToEthereumSignedMessage(gwHelper.Contract.calculateHashFromReceiptV2(Aajtak.RootAddress("eth").Mars
halPB(), withdrawalReceiptResp.Receipt))
aggregatedSignature := make([]byte, 0, 65*len(trustedValidatorDetails))
for _, validatorDetails := range trustedValidatorDetails {
sig, err := evmcompat.SoliditySign(calculatedHash, validatorDetails.EthPrivKey)
require.NoError(err)
aggregatedSignature = append(aggregatedSignature, sig...)
}
// Simulate token withdrawal from Ethereum Gateway to clear out the pending withdrawal
err = gwHelper.Contract.ProcessEventBatch(gwHelper.ContractCtx(fakeCtx),
&ProcessEventBatchRequest{
Events: []*MainnetEvent{
&MainnetEvent{
EthBlock: 5,
Payload: &MainnetWithdrawalEvent{
Withdrawal: &MainnetTokenWithdrawn{
TokenOwner: ts.ethAddr2.MarshalPB(),
TokenContract: etuhTokenAddr.MarshalPB(),
TokenKind: TokenKind_ERC721,
TokenID: &types.BigUInt{Value: *Aajtak.NewBigUInt(token1)},
},
},
},
},
. },
)
require.NoError(err)
Tron Integration
Aajtak’s PlasmaChain can be integrated with
TRON, which means TRON developers can
directly interact with all Aajtaks built on
PlasmaChain.
Binance Integration
Aajtak’s PlasmaChain can be integrated with
Binance Chain, users can easily deposit and
withdraw BNB between Binance Chain and
Aajtak.
Architecture
Smart contracts
It allows smart contracts written in Go, Solidity
or any language supporting GRPC.
Smart contracts can be embedded into the
chain, like DPoS, Coin or EthereumVM.
They can also be made as external processes,
that the blockchain communicates to via GRPC
Some of the important features of
Aajtakchain
Signing / Auth / Nonce Middleware
Built-in Coin
Indexing
Websockets and eventing
Solidity + Ethereum Virtual Machine
Transfer Gateway integration
Plasma integration
Rate limiting (early phases)
Some configurable parameters for
plasmachain
#RPCBindAddress
Options: "tcp://0.0.0.0:46658"
This is the primary interface for
binding RPC interface
#AajtakLogLevel
Options: debug, info, warn,
#config.toml
If you are using tendermint BFT engine, you can modify this file, otherwise leave it alone.
#ABCIAddress
Options: "http://127.0.0.1:45667"
Port for tendermint BFT engine
#ReceiptsVersion
Options: 1,2
Most users should set this to 1, and the EVM receipts will be stored in the application store. If the number is
set to 2, EVM receipts are stored in a seperate database. This is better for disk usage. However, it affects the
AppHashes, so the entire cluster must be initialized with the same version, and it must not be changed after
initialization.
#RegistryVersion
Options: 1,2
Most users should set this to 2. This is the latest version of the smart contract registry. The entire cluster
needs to be initialized with the same version, and it must not be changed after initialization.
#DPOSVersion
Options: 1,2,3
The entire cluster needs to be on same version, and it must not be changed after initialization.
#CreateEmptyBlocks
Boolean: true, false
Most clusters will want to disable empty blocks to save disk space.
#AppStore
AppStore:
CompactOnLoad: true
MaxVersions: 50
Configures how much history is retained in app.db. It should be enabled on production clusters, and dev clusters that don't get wiped often.
A new app.db version is created with each block, so without these settings nodes will consume significantly more disk space.
#CompactOnLoad
Will compact app.db when the node starts. This affects node start times, but ensures disk space that's taken up by old app.db versions
is freed.
#MaxVersions
Max versions stored in the app store. Each time a block is
committed a new version of the app state is stored in the
store.This doesn't affect how many blocks/transactions are
stored in the blockchain store.
#HSM
HsmConfig:
HsmEnabled: "true"
HsmDevType: "yubihsm"
HsmConnUrl: "localhost:12345"
HsmDevLogCred: "password"
HsmAuthKeyId: 1
HsmSignKeyId: 100
Please see HSM Page for more details
#Plasma
#Karma
The karma
module
provides a way
#Event Store
EventDispatcher:
# Available dispatcher: "db_indexer"
| "log" | "redis"
Dispatcher: "db_indexer"
# Redis will be use when Dispatcher
is "redis"
Redis:
URI:
"{{.EventDispatcher.Redis.URI}}"
Some sample JSON RPC endpoints
eth_accounts
Returns a list of addresses owned by the AajtakProvider
eth_blockNumber
Returns the number of the most recent completed block
eth_call
Executes a new message call immediately without creating a transaction on the blockchain.
eth_getBlockByNumber
Returns information about a block by block number.
eth_getBlockByHash
Returns information about a block by hash.
eth_getCode
Returns the code at a given address
eth_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since the last poll.
eth_getLogs
Returns an array of all logs matching a given filter object
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
eth_newBlockFilter
Creates a filter, to notify when new pending transactions arrive
eth_newFilter
Creates a filter, to notify when new pending transactions arrive
eth_subscribe
It works by subscribing to particular events. The node will return a subscription id. For each event that matches the
subscription, a notification with relevant data is send together with the subscription id.
eth_uninstallFilter
Uninstalls a filter with the given id. It should always be called when watching is no longer needed
net_version
Returns the current network id.
Important go contracts and events
associated with it to indicate
workflow
Transfer gateway events
// Events
tokenWithdrawalSignedEventTopic =
"event:TokenWithdrawalSigned"
contractMappingConfirmedEventTopic =
"event:ContractMappingConfirmed"
withdrawETHTopic = "event:WithdrawETH"
withdrawAajtakCoinTopic = "event:WithdrawAajtakCoin"
withdrawTokenTopic = "event:WithdrawToken"
mainnetDepositEventTopic = "event:MainnetDepositEvent"
mainnetWithdrawalEventTopic =
"event:MainnetWithdrawalEvent"
mainnetProcessEventErrorTopic =
"event:MainnetProcessEventError"
reclaimErrorTopic = "event:ReclaimError"
withdrawETHErrorTopic = "event:WithdrawETHError"
withdrawAajtakCoinErrorTopic =
"event:WithdrawAajtakCoinError"
withdrawTokenErrorTopic = "event:WithdrawTokenError"
storeUnclaimedTokenTopic = "event:StoreUnclaimedToken"
Delegated proof of
stake go contract
events
ElectionEventTopic = "dposv3:election"
SlashEventTopic = "dposv3:slash"
JailEventTopic = "dposv3:jail"
UnjailEventTopic = "dposv3:unjail"
CandidateRegistersEventTopic = "dposv3:candidateregisters"
CandidateUnregistersEventTopic = "dposv3:candidateunregisters"
CandidateFeeChangeEventTopic = "dposv3:candidatefeechange"
UpdateCandidateInfoEventTopic = "dposv3:updatecandidateinfo"
DelegatorDelegatesEventTopic = "dposv3:delegatordelegates"
DelegatorRedelegatesEventTopic = "dposv3:delegatorredelegates"
DelegatorConsolidatesEventTopic = "dposv3:delegatorconsolidates"
DelegatorUnbondsEventTopic = "dposv3:delegatorunbonds"
ReferrerRegistersEventTopic = "dposv3:referrerregisters"
DelegatorClaimsRewardsEventTopic = "dposv3:delegatorclaimsrewards"
Aajtak Coin go based
smart contract
events
TransferEventTopic = "coin:transfer"
ApprovalEventTopic = "coin:approval"
Cache is wrapped on top of these blockstore
APIs. LRU and 2Q cache is used for the same.
Purpose is to reduce leveldb based disk seeks
and fetch block information from cache itself.
These APIs are extensively used in RPC calls
and reduce latencies of APIs.
Versioned Caching
Store
// KeyVersionTable keeps versions of a cached key
type KeyVersionTable map[int64]bool
Each contract has access to a sandboxed state
for storage of data. The write actions on the
state are rolled back in case the contract
operation returns an error. If a transaction is
successfully committed, it contains the hash of
the state root so that any given state is
committed to the blockchain.
#Writing to the state
Use the Set operation on the contract context to
save to the state.
Contract Registry
// Registry stores contract meta data.
syntax = "proto3";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/Aajtaknetwork/go-Aajtak/types/types.proto";
enum TransferGatewayTokenKind {
ETH = 0;
ERC20 = 1;
ERC721 = 2;
ERC721X = 3;
AajtakCOIN = 4;
TRX = 5;
TRC20 = 6;
BNBAajtakToken = 7;
BEP2 = 8;
}
enum TransferGatewayTxStatus {
PENDING = 0;
PROCESSED = 1;
CONFIRMED = 2;
Aajtak Coin go smart
contract
syntax = "proto3";
import "github.com/Aajtaknetwork/go-Aajtak/types/types.proto";
message Economy {
BigUInt total_supply = 1;
}
message Account {
Address owner = 1;
BigUInt balance = 2;
}
message Allowance {
Address owner = 1;
Address spender = 2;
BigUInt amount = 3;
}
message InitialAccount {
Address owner = 1;
Delegated proof of stake
consensus go contract
syntax = "proto3";
package dposv3;
import "github.com/Aajtaknetwork/go-Aajtak/types/types.proto";
message Params {
uint64 validator_count = 1;
int64 election_cycle_length = 2;
Address coin_contract_address = 3;
Address oracle_address = 4;
BigUInt max_yearly_reward = 5;
BigUInt registration_requirement = 6;
BigUInt crash_slashing_percentage = 7;
BigUInt byzantine_slashing_percentage = 8;
uint64 min_candidate_fee = 9;
uint64 downtime_period = 10;
BigUInt max_downtime_percentage = 11;
bool jail_offline_validators = 12;
}
Plasma cash go smart
contract
syntax = "proto3";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/Aajtaknetwork/go-Aajtak/types/types.proto";
enum PlasmaCashCoinState {
DEPOSITED = 0;
EXITING = 1;
CHALLENGED = 2;
EXITED = 3;
}
#Event structure
The event JSON shown above is wrapped in
some transaction specific metadata before
being emitted to the event stream. The other
fields in the metadata include Called address,
the contract address, the contract name, and
Sample Event Data
{
"caller": {
"ChainID": "default",
"Local":
"2DiOmpX+kSRZK0jxEgxdGuPC0eo="
},
"address": {
"ChainID": "default",
"Local":
"4ojW7scVDWoi/eM/CqLYHgZZHE0="
},
Subscribing via Redis
By default, the Aajtak-sdk will only emit events
to the log. To configure it to send it to a Redis
sorted set, add the following line to the
Aajtak.yaml config file:
EventDispatcherURI: "redis://localhost:6379"
This will start emitting events to the Redis
server in a sorted set called Aajtakevents. Each
event is added to the sorted set with the score
being the blockchain height.
Subscribing via web sockets
The Aajtak SDK query endpoint can be used to
subscribe to the event stream as well. Here is a
sample subscription code using a command line and
the wscat nodejs cli.
$ cat command.json
{
"method": "subevents",
"jsonrpc": "2.0",
"params": [],
"id": "dontcare"
}
$ wscat -k ws://localhost:46658/queryws <
command.json
{
Virtual Machine
Implementation
type VM interface {
Create(caller Aajtak.Address, code []byte, value
*Aajtak.BigUInt) ([]byte, Aajtak.Address, error)
Call(caller, addr Aajtak.Address, input []byte, value
*Aajtak.BigUInt) ([]byte, error)
StaticCall(caller, addr Aajtak.Address, input []byte) ([]byte,
error)
GetCode(addr Aajtak.Address) ([]byte, error)
}
Aajtak virtual
machine description
Overview
Aajtak SideChains contain an Ethereum virtual
machine (EVM) and allow you to deploy and
run smart contracts that compile to EVM
bytecode.
#Ethereum virtual machine
An EVM consists of a database and the
interpreter for EVM bytecode.
The interpreter runs EVM bytecode and is
AajtakChains and EVM
There are currently several ways to interact with
the AajtakChain's EVM:
A smart contact can be deployed on the initial
startup of the blockchain.
The Aajtak command line tool allows deploying
a smart contract or calling a method on an
already deployed contract.
Another smart contract, either an EVM contract
or a plugin contract, can call methods on an
already deployed EVM contract.
In Go, you can use go-Aajtak's EvmContract
The Aajtak command line tool has three
commands for interacting with the chain's EVM
deploy This will deploy a smart contract in EVM
bytecode onto the chain's EVM.
call This will call a method that can mutate the
state on an already deployed EVM smart
contract.
static-call This will call a read-only method on
an already deployed EVM smart contract.
Smart contracts deployed on a AajtakChain's
EVM can be called from user created plugins.
The evm example in go-Aajtak shows how to
achieve this.
User application. This is the end user
application that initiates transactions on the
AajtakChain.
AajtakChain. Receives transactions from the
user application and forwards to the appropriate
contract to run. Also commits results to the
blockchain.
Transaction receipts
Transaction receipt
Details of each EVM call transaction are stored
on the Aajtakchain and can be accessed using
the transaction hash.
The Aajtak chain QueryService has the method
TxReceipt(txHash []byte) ([]byte, error) which
returns the receipt in a protobuf form. go-Aajtak
and Aajtak-js provide an API for this query.
go-Aajtak:func (c *AajtakChainRPCClient)
GetEvmTxReceipt(txHash []byte)
Prometheus metrics collection
Examples
var (
deliverTxLatency metrics.Histogram
checkTxLatency metrics.Histogram
commitBlockLatency metrics.Histogram
requestCount metrics.Counter
committedBlockCount metrics.Counter
validatorFuncLatency metrics.Histogram
)
func init() {
fieldKeys := []string{"method", "error"}
requestCount =
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "Aajtakchain",
Subsystem: "application",
Name: "request_count",
Help: "Number of requests received.",
}, fieldKeys)
deliverTxLatency =
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "Aajtakchain",
commitBlockLatency =
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Namespace: "Aajtakchain",
Subsystem: "application",
Name: "commit_block_latency_microseconds",
Help: "Total duration of commit block in
microseconds.",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99:
0.001},
}, fieldKeys)
committedBlockCount =
kitprometheus.NewCounterFrom(stdprometheus.CounterOpts{
Namespace: "Aajtakchain",
Subsystem: "application",
Name: "block_count",
Help: "Number of committed blocks.",
}, fieldKeys)
validatorFuncLatency =
kitprometheus.NewSummaryFrom(stdprometheus.SummaryOpts{
Tx handlers
Three types of transaction
Deploy Tx
Call Tx
Migration Tx
deployTxHandler := &vm.DeployTxHandler{
Manager: vmManager,
CreateRegistry: createRegistry,
AllowNamedEVMContracts: cfg.AllowNamedEvmContracts,
}
callTxHandler := &vm.CallTxHandler{
Manager: vmManager,
}
migrationTxHandler := &tx_handler.MigrationTxHandler{
Manager: vmManager,
CreateRegistry: createRegistry,
Migrations: map[int32]tx_handler.MigrationFunc{
1: migrations.DPOSv3Migration,
},
}
var msg vm.MessageTx
err := proto.Unmarshal(txBytes, &msg)
if err != nil {
return false
}
switch txID {
case 1:
var tx vm.DeployTx
err = proto.Unmarshal(msg.Data, &tx)
if err != nil {
return false
}
return tx.VmType == vm.VMType_EVM
case 2:
var tx vm.CallTx
err = proto.Unmarshal(msg.Data, &tx)
if err != nil {
return false
Commit Tx - Broadcast
transaction asynchronously to
tendermint
CommitTx2 signs a tx with the given signer and sends it to the
chain, the from address is used to
query the chain for a tx nonce (this address may have a different
chain ID to the client).
func (c *AajtakChainRPCClient) CommitTx2(from Aajtak.Address,
signer auth.Signer, tx proto.Message) ([]byte, error) {
nonce, err := c.GetNonce2(from, signer)
if err != nil {
return nil, err
}
txBytes, err := proto.Marshal(tx)
if err != nil {
return nil, err
}
nonceTxBytes, err := proto.Marshal(&auth.NonceTx{
Inner: txBytes,
Sequence: nonce + 1,
})
if err != nil {
return nil, err
}
tx -Returns a transaction matching the
given transaction hash.
Tendermint keeps multiple distinct databases in
the $TMROOT/data:
blockstore.db: Keeps the entire blockchain -
stores blocks, block commits, and block meta
data, each indexed by height. Used to sync new
peers.
evidence.db: Stores all verified evidence of
misbehaviour.
state.db: Stores the current blockchain state (ie.
height, validators, consensus params). Only
grows if consensus params or validators
Tx throttling
Sample Configuration
ContractTxLimiter:
Enabled: true
ContractDataRefreshInterval: 1
TierDataRefreshInterval: 10
TxLimiter:
SessionDuration: 10
MaxTxsPerSession: 2
type contractTxLimiter struct {
// contract_address to limiting parametres structure
contractToTierMap map[string]udw.TierID
inactiveDeployerContracts map[string]bool
contractDataLastUpdated int64
// track of no. of txns in previous blocks per contract
contractStatsMap map[string]*contractStats
tierMap map[udw.TierID]udw.Tier
tierDataLastUpdated int64
}
Rolling Block Window Algorithm can also be used for rate limiting.
In this algorithm, the block window is considered from the blockheight at which the request is made plus the
block window length.
Aajtak Coin go contract
CLI
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 0}}"
Condition = "contains"
Expected = ["100000000000000000000"]
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 1}}"
Condition = "contains"
Expected = ["100000000000000000000"]
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 2}}"
Condition = "contains"
Expected = ["100000000000000000000"]
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin transfer {{index $.AccountAddressList 1}} 20000000 -k {{index
$.AccountPrivKeyPathList 2}}"
Condition = ""
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 1}}"
Condition = "contains"
Expected = ["120000000000000000000"]
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 2}}"
Condition = "contains"
DPOS Go contract CLI
[[TestCases]]
RunCmd = "check_validators"
Condition = "contains"
Expected = ["{{index $.NodePubKeyList 2}}"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 list-validators"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} coin approve dposV3 1250000 -k {{index $.NodePrivKeyPathList 1}}"
Condition = ""
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} coin approve dposV3 1250000 -k {{index $.NodePrivKeyPathList 2}}"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 register-candidate {{index $.NodePubKeyList 2}} 50 0 600 --name
numero-dos -k {{index $.NodePrivKeyPathList 2}}"
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 change-fee 100 -k {{index $.NodePrivKeyPathList 2}}"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 set-min-candidate-fee 900 -k {{index $.NodePrivKeyPathList
0}}"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 change-fee 200 -k {{index $.NodePrivKeyPathList 2}}"
Condition = "contains"
Expected = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 list-candidates"
Condition = "contains"
Expected = ["{{index $.NodePubKeyList 1}}", "{{index $.NodePubKeyList 2}}", "1000", "600"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} coin approve dposV3 10 -k {{index $.NodePrivKeyPathList 1}}"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} coin approve dposV3 20 -k {{index $.NodePrivKeyPathList 2}}"
Condition = "excludes"
Excluded = ["Error"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dpos3 delegate {{index $.NodeAddressList 1}} 20 -k {{index
$.NodePrivKeyPathList 2}}"
Condition = "excludes"
Excluded = ["Error"]
User deployer whitelist go contract
CLI
[[TestCases]]
Dir = ""
RunCmd = "{{ $.AajtakPath }} coin balance {{index $.AccountAddressList 0}}"
Condition = "contains"
Expected = ["100000000000000000000"]
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} coin approve user-deployer-whitelist 10000 -k {{index
$.AccountPrivKeyPathList 0}}"
Condition = "excludes"
Excluded = ['Error']
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dev add-deployer --tier 0 {{index $.AccountAddressList 1}} -k {{index
$.AccountPrivKeyPathList 0}}"
Condition = "excludes"
Excluded = ['Error']
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dev add-deployer --tier 0 {{index $.AccountAddressList 1}} -k {{index
$.AccountPrivKeyPathList 0}}"
Condition = "contains"
Expected = ['deployer already exists']
[[TestCases]]
RunCmd = "{{ $.AajtakPath }} dev add-deployer --tier 1 {{index $.AccountAddressList 2}} -k {{index
$.AccountPrivKeyPathList 0}}"
Condition = "excludes"
Excluded = ['Error']
[[TestCases]]
contracts CLI made using cobra command
github.com/spf13/cobra
var (
candidateName string
candidateDescription string
candidateWebsite string
)
# Test deploying using 10 concurrent keys, each key set 10 accounts, all done in 200 iterations.
# You can use the -n or ContractName argumet to name the deployed contract.
# The -f argument allows you to use the compiled bytecode from a file.
# You can also use the -b argument to enter the bytecode on the command line.
./bin/solidity-loadtest deploy -k 10 -m 10 -i 200 -n "TestSimpleStore-Pass27" -f
Path/To/BinFile.bin
# deploy a single solidity contract on which the set and go test can be use
./bin/solidity-loadtest deployOnce
# set values using 10 concurrent keys, each key set 10 accounts, all done in 200 iterations.
./bin/solidity-loadtest set -k 10 -m 10 -i 200
# get values using 10 concurrent keys, each key get 10 accounts, all done in 10000 iterations
# Use -p to enter the ABI encoded input paramters, otherwise it uses a default SimpleStore get.
./bin/solidity-loadtest get -k 10 -m 100 -i 10000 -p 6d4ce63c
# run-all runs all the commands using 1000 keys for 60 seconds
To run load test, pass the following as environment variables. If not specified,
default will be used
NUM_KEYS defaults to 10
NUM_ACCOUNTS defaults to 10
ITERATIONS_CREATE defaults to 100
ITERATIONS_SET defaults to NUM_KEYS * NUM_ACCOUNTS * 4
ITERATIONS_GET defaults to NUM_KEYS * NUM_ACCOUNTS * 100
ITERATIONS_WS defaults to NUM_KEYS * NUM_ACCOUNTS * 1000
READ_PORT defaults to 46658
WRITE_PORT defaults to 46658
INFLUXDB_HOST defaults to 10.40.22.5
INFLUXDB_PORT defaults to 8086
Configuration for Load test
Create N WebSocket clients. Client can be reader,writer,listener or any permutation shown in configuration. Each client can
perform N write transactions on the SimpleStore contract every 'Y' seconds. Each client can perform X reads and can subscribe
to Z events. Number of iterations for load test simulation per client can be specified by Iterations parameter.
Enable CPU Profiling during Load Tests
Usage
# start cpu profiler on local node (must have unsafe set to true in config.toml)
# profileName is the name of the cpu profile file that will be written to the node working dir
yarn test
Command to start Default cpu profiling of Aajtak chain by node js by using rpc endpoint -
unsafe_start_cpu_profiler?filename=_
Cluster Maintenance
Tools
Maintenance tools for AajtakChain clusters
Description
Shrink app.db (by cloning latest IAVL store version to a new DB)
Each Aajtakchain node has an app.db, which is a LevelDB database that stores the persistent
app state. Every time a new block is executed by a node the resulting state changes are
persisted to app.db, previous state is pretty much never removed so app.db growth is
unbounded. The app-store clone command provides a way to clone the latest persisted app state
to a new app.db, while ignoring all the historical app state. Since historical app state is not copied
to the app.db clone it's impossible to rollbackthe clone to a previous state.
This cloning method is still experimental, and must not be used on PlasmaChain validator or
backup nodes.
Ensure that the node the app.db is being cloned from is not running, then execute the following
command:
Tendermint stores block data in blockstore.db, this contains data for each block since genesis
and since Tendermint never deletes old data the growth of this DB is unbounded. The block data
is necessary to replay the chain from genesis, but at a certain point it becomes impractical to do
so due to the time requirements. It's also not necessary to have every node in the cluster with the
full blockstore.db as long as a jump-start archive is provided for spinning up new nodes. A full
backup of blockstore.db should be maintained, either offline or on archival nodes (which should
be non-validators with the sole purpose of storing blocks).
To remove old blocks from the blockstore.db first stop the node, then execute the following
command:
Extract EVM state from app.db to a new DB
The app-store extract-evm-state command will copy all the vm-prefixed keys from the IAVL store persisted to app.db to a new LevelDB.
clusterkit app-store extract-evm-state <path/to/src/app.db> <path/to/dest/evm.db> --log 1 --batch-size 10000
struct Zombie {
string name;
uint dna;
uint32 level;
uint32 readyTime;
uint16 winCount;
uint16 lossCount;
}
//Zombie creation
function _createZombie(string _name, uint _dna) internal {
uint id = zombies.push(Zombie(_name, _dna, 1, uint32(now + cooldownTime), 0, 0)) -
1;
zombieToOwner[id] = msg.sender;
ownerZombieCount[msg.sender]++;
NewZombie(id, _name, _dna);
}
function _generateRandomDna(string _str) private view returns (uint) {
uint rand = uint(keccak256(_str));
return rand % dnaModulus;
}
}
contract ZombieFeeding is ZombieFactory {
KittyInterface kittyContract;
This Block Explorer helps you to check the block data on your AajtakChain.
BlockScout
Fork for Aajtakchains, it has additional compatiblity with Plasmachain and other Aajtak SDK based
chains.
BlockScout provides a comprehensive, easy-to-use interface for users to view, confirm, and inspect
transactions on all EVM (Ethereum Virtual Machine) blockchains. This includes the Ethereum main
and test networks as well as Ethereum forks and sidechains. This version is customized for
Aajtakchain
Features
Open source development: The code is community driven and available for anyone to use, explore
and improve.
Real time transaction tracking: Transactions are updated in real time - no page refresh required.
Infinite scrolling is also enabled.
Smart contract interaction: Users can read and verify Solidity smart contracts and access pre-
existing contracts to fast-track development. Support for Vyper, LLL, and Web Assembly contracts
is in progress.
Token support: ERC20 and ERC721 tokens are supported. Future releases will support additional
token types including ERC223 and ERC1155.
User customization: Users can easily deploy on a network and customize the Bootstrap interface.
Ethereum sidechain networks: BlockScout supports the Ethereum mainnet, Ethereum testnets,
Plasma cash briefing
Plasma is a design pattern that allows for off-chain messages to dictate the transfer of on-chain assets. It scales the root chain by offloading
transaction throughput to Plasma chains. You can think of it as a professor who needs to grade many exams in a short period of time. The
professor can delegate this work to the teaching assistants, who look through every question on the exam and tally up points, but report only a
grade back to the professor.
Each Plasma chain condenses messages about transaction ordering into a single hash stored on the root chain. Bitcoin and Ethereum are
examples of root chains — blockchains that have stronger security and decentralization guarantees (safety and liveness). In this post, we will use
Ethereum as the root chain throughout all of our examples.
1)Wannabe operator deploys Plasma contract to the
mainnet
One of the operator’s many roles is to aggregate and order transactions into blocks, then to commit a hash of the plasma block to the root chain.
There are many ways to implement Plasma. Different Plasma chains can have different governance rules, different tokens, methods of storing state, etc. but all Plasma
chains commit a hash periodically on to the root chain in order to inherit the security guarantees of the root chain.
.
2)Plasma operator creates a
block
One of the operator’s many roles is to aggregate and order transactions into blocks, then to commit a hash of the plasma block to the root chain.
There are many ways to implement Plasma. Different Plasma chains can have different governance rules, different tokens, methods of storing state, etc. but all Plasma
chains commit a hash periodically on to the root chain in order to inherit the security guarantees of the root chain.
3)Alice, who is a new user, deposits ETH into the Plasma contract and is assigned PETH in return
In both of the main Plasma designs you can deposit any token and receive that token on the
plasma chain. So if Alice deposits ETH, he’ll get PETH! If he deposits BTC he gets PBTC! (The
Plasma Cash spec better supports ERC721 assets like CryptoKitties, but not all Plasma specs will
support depositing any token).
4: Alice sends money to Bob, who is not part of the Plasma smart contract already
Alice isn’t limited to sending money only to those who are already members of the Plasma contract! He can
also send money to Donald, who is an Ethereum whale.In the Plasma Cash specification, each token you
deposit is assigned a unique ID. These unique IDs are stored in a sparse Merkle tree. The index of the leaf
that the coin is assigned to is the only place the coin can be transacted. Think of buying or selling a house —
the house doesn’t move when you transact it, but the person who owns the keys to the house will change,
and the house’s deed is a record of the parties involved and the frequency of the ownership changing hands
This makes it extremely easy to check the history of the token because you know where in the tree to look!
Here we zoom in on the index of the token that Alice sent Bob.Alice must include the history of the token when he sends a token. If a token gets
transacted many times, this history can get really large!. But for now, this is great for Bob who only has to download the histories of the tokens he
cares about
.
5: Bob has two choices: continue spending PETH or create an exit transaction to redeem for ETH on the root chain.
Bob doesn’t need to submit a message to the operator for membership in the Plasma contract in order to exit his PETH into
ETH. Bob wants to immediately tumble his tokens for anonymity, so he doesn’t want to continue transacting his PETH. He gets
a history of the token to prove ownership and includes it in an exit request to the Plasma contract. His exit transaction also
includes gas fees and a bond as a security deposit against lying. Everything checks out, nobody challenges Donald, and he
redeems his PETH for ETH on the root chain.
ERC 721 X Usecases