mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Add struct get state endpoint
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
USAGE="Available options:
|
USAGE="Available options:
|
||||||
doc Start documentation UI at http://loclahost:8001 and the mock up server at http://loclahost:4010
|
doc Start documentation UI at http://localhost:8001 and the mock up server at http://localhost:4010
|
||||||
mock Start the mock up server at http://loclahost:4010
|
mock Start the mock up server at http://localhost:4010
|
||||||
editor Start the documentation editor at http://loclahost:8002
|
editor Start the documentation editor at http://localhost:8002
|
||||||
stop Stop all runing services started using this script
|
stop Stop all runing services started using this script
|
||||||
help display this message"
|
help display this message"
|
||||||
|
|
||||||
|
|||||||
17
api/state.go
Normal file
17
api/state.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hermeznetwork/hermez-node/common"
|
||||||
|
"github.com/hermeznetwork/hermez-node/db/historydb"
|
||||||
|
"github.com/hermeznetwork/hermez-node/eth"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Status define status of the network
|
||||||
|
type Status struct {
|
||||||
|
Network historydb.Network `json:"network"`
|
||||||
|
Metrics historydb.Metrics `json:"metrics"`
|
||||||
|
Rollup eth.RollupVariables `json:"rollup"`
|
||||||
|
Auction eth.AuctionVariables `json:"auction"`
|
||||||
|
WithdrawalDelayer eth.WDelayerVariables `json:"withdrawalDelayer"`
|
||||||
|
RecommendedFee common.RecommendedFee `json:"recommendedFee"`
|
||||||
|
}
|
||||||
135
api/swagger.yml
135
api/swagger.yml
@@ -2177,7 +2177,11 @@ components:
|
|||||||
$ref: '#/components/schemas/PaginationInfo'
|
$ref: '#/components/schemas/PaginationInfo'
|
||||||
State:
|
State:
|
||||||
type: object
|
type: object
|
||||||
description: Gobal statistics of the network.
|
description: Gobal variables of the network
|
||||||
|
properties:
|
||||||
|
network:
|
||||||
|
type: object
|
||||||
|
description: Gobal statistics of the network
|
||||||
properties:
|
properties:
|
||||||
lastBlock:
|
lastBlock:
|
||||||
allOf:
|
allOf:
|
||||||
@@ -2185,15 +2189,24 @@ components:
|
|||||||
- description: Last synchronized Etherum block.
|
- description: Last synchronized Etherum block.
|
||||||
- example: 3457437
|
- example: 3457437
|
||||||
lastBatch:
|
lastBatch:
|
||||||
allOf:
|
$ref: '#/components/schemas/Batch'
|
||||||
- $ref: '#/components/schemas/BatchNum'
|
|
||||||
- description: Last batch that has been forged.
|
|
||||||
- example: 76523
|
|
||||||
currentSlot:
|
currentSlot:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/SlotNum'
|
- $ref: '#/components/schemas/SlotNum'
|
||||||
- description: Slot where batches are currently being forged.
|
- description: Slot where batches are currently being forged.
|
||||||
- example: 2334
|
- example: 2334
|
||||||
|
nextForgers:
|
||||||
|
$ref: '#/components/schemas/NextForgers'
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- lastBlock
|
||||||
|
- lastBatch
|
||||||
|
- currentSlot
|
||||||
|
- nextForgers
|
||||||
|
metrics:
|
||||||
|
type: object
|
||||||
|
description: Metrics of the network
|
||||||
|
properties:
|
||||||
transactionsPerBatch:
|
transactionsPerBatch:
|
||||||
type: number
|
type: number
|
||||||
description: Average transactions per batch in the last 24 hours.
|
description: Average transactions per batch in the last 24 hours.
|
||||||
@@ -2218,26 +2231,69 @@ components:
|
|||||||
type: number
|
type: number
|
||||||
description: Average fee percentage paid for L2 transactions in the last 24 hours.
|
description: Average fee percentage paid for L2 transactions in the last 24 hours.
|
||||||
example: 1.54
|
example: 1.54
|
||||||
nextForgers:
|
additionalProperties: false
|
||||||
$ref: '#/components/schemas/NextForgers'
|
require:
|
||||||
recommendedFee:
|
- transactionsPerBatch
|
||||||
$ref: '#/components/schemas/RecommendedFee'
|
- batchFrequency
|
||||||
governance:
|
- transactionsPerSecond
|
||||||
type: object
|
- totalAccounts
|
||||||
description: Network setings that are updatable by the governance.
|
- totalBJJs
|
||||||
properties:
|
- avgTransactionFee
|
||||||
rollup:
|
rollup:
|
||||||
type: object
|
type: object
|
||||||
description: Rollup parameters.
|
description: Rollup parameters
|
||||||
properties:
|
properties:
|
||||||
forgeTimeout:
|
forgeL1L2BatchTimeout:
|
||||||
type: integer
|
type: integer
|
||||||
description: Time delay between the beggining of a slot and the beggining of the period in which anyone can forge if the auction winner of the slot hasn't forged any batch yet. Time is measured in Ethereum blocks.
|
description: Max ethereum blocks after the last L1-L2-batch, when exceeds the timeout only L1-L2-batch are allowed.
|
||||||
example: 5
|
example: 5
|
||||||
feeAddToken:
|
feeAddToken:
|
||||||
type: integer
|
type: integer
|
||||||
description: fee to pay when registering tokens into the network.
|
description: Fee to pay when registering tokens into the network.
|
||||||
example: 5698
|
example: 5698
|
||||||
|
withdrawalDelay:
|
||||||
|
type: integer
|
||||||
|
description: Withdraw delay in seconds
|
||||||
|
example: 432000
|
||||||
|
buckets:
|
||||||
|
type: array
|
||||||
|
description: List of buckets state
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
ceilUSD:
|
||||||
|
type: integer
|
||||||
|
description: Max USD value
|
||||||
|
example: 1000
|
||||||
|
blockStamp:
|
||||||
|
type: integer
|
||||||
|
description: Last time a withdrawal was added ( or removed if the bucket was full)
|
||||||
|
example: 4475934
|
||||||
|
withdrawals:
|
||||||
|
type: integer
|
||||||
|
description: Available withdrawals of the bucket
|
||||||
|
example: 4
|
||||||
|
blockWithdrawalRate:
|
||||||
|
type: integer
|
||||||
|
description: Every `blockWithdrawalRate` blocks add 1 withdrawal
|
||||||
|
example: 8
|
||||||
|
maxWithdrawals:
|
||||||
|
type: integer
|
||||||
|
description: Max withdrawals the bucket can hold
|
||||||
|
example: 4
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- ceilUSD
|
||||||
|
- blockStamp
|
||||||
|
- withdrawals
|
||||||
|
- blockWithdrawalRate
|
||||||
|
- maxWithdrawals
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- forgeL1L2BatchTimeout
|
||||||
|
- feeAddToken
|
||||||
|
- withdrawalDelay
|
||||||
|
- buckets
|
||||||
auction:
|
auction:
|
||||||
type: object
|
type: object
|
||||||
description: Auction parameters.
|
description: Auction parameters.
|
||||||
@@ -2249,7 +2305,7 @@ components:
|
|||||||
- example: "0x997dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x997dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
slotDeadline:
|
slotDeadline:
|
||||||
type: integer
|
type: integer
|
||||||
description: Number of blocks at the end of a slot in which any coordinator can forge if the winner has not forged one before.
|
description: Number of blocks after the beginning of a slot after which any coordinator can forge if the winner has not forged any batch in that slot.
|
||||||
example: 3
|
example: 3
|
||||||
closedAuctionSlots:
|
closedAuctionSlots:
|
||||||
type: integer
|
type: integer
|
||||||
@@ -2279,26 +2335,36 @@ components:
|
|||||||
items:
|
items:
|
||||||
type: integer
|
type: integer
|
||||||
example: [80,10,10]
|
example: [80,10,10]
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- bootCoordinator
|
||||||
|
- slotDeadline
|
||||||
|
- closedAuctionSlots
|
||||||
|
- openAuctionSlots
|
||||||
|
- defaultSlotSetBid
|
||||||
|
- outbidding
|
||||||
|
- donationAddress
|
||||||
|
- allocationRatio
|
||||||
withdrawalDelayer:
|
withdrawalDelayer:
|
||||||
type: object
|
type: object
|
||||||
description: Withdrawal delayer parameters.
|
description: Withdrawal delayer parameters
|
||||||
properties:
|
properties:
|
||||||
rollupAddress:
|
hermezRollupAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the rollup smart contract.
|
- description: Ethereum address of the rollup smart contract.
|
||||||
- example: "0x777dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x777dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
governanceAddress:
|
hermezGovernanceDAOAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum address of the governance mechanism.
|
- description: Ethereum address of the governance DAO.
|
||||||
- example: "0x667dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x667dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
whitheHackerGroupAddress:
|
whiteHackGroupAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum Address that can claim the funds in an emergency when the maximum emergency mode time is exceeded.
|
- description: Ethereum Address that can claim the funds in an emergency when the maximum emergency mode time is exceeded.
|
||||||
- example: "0x557dc4262BCDbf85190C01c996b4C06a461d2430"
|
- example: "0x557dc4262BCDbf85190C01c996b4C06a461d2430"
|
||||||
keeperAddress:
|
hermezKeeperAddress:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: '#/components/schemas/EthereumAddress'
|
- $ref: '#/components/schemas/EthereumAddress'
|
||||||
- description: Ethereum Address that can enable emergency mode and modify the delay to make a withdrawal.
|
- description: Ethereum Address that can enable emergency mode and modify the delay to make a withdrawal.
|
||||||
@@ -2315,7 +2381,26 @@ components:
|
|||||||
emergencyMode:
|
emergencyMode:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Indicates if emergency mode has been activated.
|
description: Indicates if emergency mode has been activated.
|
||||||
|
example: false
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- hermezRollupAddress
|
||||||
|
- hermezGovernanceDAOAddress
|
||||||
|
- whiteHackGroupAddress
|
||||||
|
- hermezKeeperAddress
|
||||||
|
- withdrawalDelay
|
||||||
|
- emergencyModeStartingTime
|
||||||
|
- emergencyMode
|
||||||
|
recommendedFee:
|
||||||
|
$ref: '#/components/schemas/RecommendedFee'
|
||||||
|
additionalProperties: false
|
||||||
|
require:
|
||||||
|
- network
|
||||||
|
- metrics
|
||||||
|
- rollup
|
||||||
|
- auction
|
||||||
|
- withdrawalDelayer
|
||||||
|
- recomendedFee
|
||||||
PaginationInfo:
|
PaginationInfo:
|
||||||
type: object
|
type: object
|
||||||
description: Give pagination information
|
description: Give pagination information
|
||||||
|
|||||||
@@ -154,3 +154,21 @@ type BatchAPI struct {
|
|||||||
FirstItem int `json:"-" meddler:"first_item"`
|
FirstItem int `json:"-" meddler:"first_item"`
|
||||||
LastItem int `json:"-" meddler:"last_item"`
|
LastItem int `json:"-" meddler:"last_item"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Network define status of the network
|
||||||
|
type Network struct {
|
||||||
|
LastBlock int64 `json:"lastBlock"`
|
||||||
|
LastBatch BatchAPI `json:"lastBatch"`
|
||||||
|
CurrentSlot int64 `json:"currentSlot"`
|
||||||
|
NextForgers []HistoryCoordinator `json:"nextForgers"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metrics define metrics of the network
|
||||||
|
type Metrics struct {
|
||||||
|
TransactionsPerBatch float64 `json:"transactionsPerBatch"`
|
||||||
|
BatchFrequency float64 `json:"batchFrequency"`
|
||||||
|
TransactionsPerSecond float64 `json:"transactionsPerSecond"`
|
||||||
|
TotalAccounts int64 `json:"totalAccounts"`
|
||||||
|
TotalBJJs int64 `json:"totalBJJs"`
|
||||||
|
AvgTransactionFee float64 `json:"avgTransactionFee"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,21 +63,21 @@ type Coordinator struct {
|
|||||||
// AuctionVariables are the variables of the Auction Smart Contract
|
// AuctionVariables are the variables of the Auction Smart Contract
|
||||||
type AuctionVariables struct {
|
type AuctionVariables struct {
|
||||||
// Boot Coordinator Address
|
// Boot Coordinator Address
|
||||||
DonationAddress ethCommon.Address
|
DonationAddress ethCommon.Address `json:"donationAddress" meddler:"donation_address"`
|
||||||
// Boot Coordinator Address
|
// Boot Coordinator Address
|
||||||
BootCoordinator ethCommon.Address
|
BootCoordinator ethCommon.Address `json:"bootCoordinator" meddler:"boot_coordinator"`
|
||||||
// The minimum bid value in a series of 6 slots
|
// The minimum bid value in a series of 6 slots
|
||||||
DefaultSlotSetBid [6]*big.Int
|
DefaultSlotSetBid [6]*big.Int `json:"defaultSlotSetBid" meddler:"default_slot_set_bid,json"`
|
||||||
// Distance (#slots) to the closest slot to which you can bid ( 2 Slots = 2 * 40 Blocks = 20 min )
|
// Distance (#slots) to the closest slot to which you can bid ( 2 Slots = 2 * 40 Blocks = 20 min )
|
||||||
ClosedAuctionSlots uint16
|
ClosedAuctionSlots uint16 `json:"closedAuctionSlots" meddler:"closed_auction_slots"`
|
||||||
// Distance (#slots) to the farthest slot to which you can bid (30 days = 4320 slots )
|
// Distance (#slots) to the farthest slot to which you can bid (30 days = 4320 slots )
|
||||||
OpenAuctionSlots uint16
|
OpenAuctionSlots uint16 `json:"openAuctionSlots" meddler:"open_auction_slots"`
|
||||||
// How the HEZ tokens deposited by the slot winner are distributed (Burn: 40% - Donation: 40% - HGT: 20%)
|
// How the HEZ tokens deposited by the slot winner are distributed (Burn: 40% - Donation: 40% - HGT: 20%)
|
||||||
AllocationRatio [3]uint16
|
AllocationRatio [3]uint16 `json:"allocationRatio" meddler:"allocation_ratio,json"`
|
||||||
// Minimum outbid (percentage) over the previous one to consider it valid
|
// Minimum outbid (percentage) over the previous one to consider it valid
|
||||||
Outbidding uint16
|
Outbidding uint16 `json:"outbidding" meddler:"outbidding"`
|
||||||
// Number of blocks at the end of a slot in which any coordinator can forge if the winner has not forged one before
|
// Number of blocks at the end of a slot in which any coordinator can forge if the winner has not forged one before
|
||||||
SlotDeadline uint8
|
SlotDeadline uint8 `json:"slotDeadline" meddler:"slot_deadline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuctionState represents the state of the Rollup in the Smart Contract
|
// AuctionState represents the state of the Rollup in the Smart Contract
|
||||||
|
|||||||
@@ -110,11 +110,21 @@ type RollupPublicConstants struct {
|
|||||||
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
WithdrawDelayerContract ethCommon.Address `json:"withdrawDelayerContract"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bucket are the variables of each Bucket of Rollup Smart Contract
|
||||||
|
type Bucket struct {
|
||||||
|
CeilUSD uint64 `json:"ceilUSD"`
|
||||||
|
BlockStamp uint64 `json:"blockStamp"`
|
||||||
|
Withdrawals uint64 `json:"withdrawals"`
|
||||||
|
BlockWithdrawalRate uint64 `json:"blockWithdrawalRate"`
|
||||||
|
MaxWithdrawals uint64 `json:"maxWithdrawals"`
|
||||||
|
}
|
||||||
|
|
||||||
// RollupVariables are the variables of the Rollup Smart Contract
|
// RollupVariables are the variables of the Rollup Smart Contract
|
||||||
type RollupVariables struct {
|
type RollupVariables struct {
|
||||||
FeeAddToken *big.Int
|
FeeAddToken *big.Int `json:"feeAddToken" meddler:"fee_addtoken"`
|
||||||
ForgeL1L2BatchTimeout int64
|
ForgeL1L2BatchTimeout int64 `json:"forgeL1L2BatchTimeout" meddler:"forge_l1l2_timeout"`
|
||||||
WithdrawalDelay uint64
|
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay"`
|
||||||
|
Buckets [RollupConstNumBuckets]Bucket `json:"buckets" meddler:"buckets,json"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueueStruct is the queue of L1Txs for a batch
|
// QueueStruct is the queue of L1Txs for a batch
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
WithdrawalDelayer "github.com/hermeznetwork/hermez-node/eth/contracts/withdrawdelayer"
|
WithdrawalDelayer "github.com/hermeznetwork/hermez-node/eth/contracts/withdrawdelayer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WDelayerConstants are the constants of the Rollup Smart Contract
|
// WDelayerConstants are the constants of the Withdrawal Delayer Smart Contract
|
||||||
type WDelayerConstants struct {
|
type WDelayerConstants struct {
|
||||||
// Max Withdrawal Delay
|
// Max Withdrawal Delay
|
||||||
MaxWithdrawalDelay uint64 `json:"maxWithdrawalDelay"`
|
MaxWithdrawalDelay uint64 `json:"maxWithdrawalDelay"`
|
||||||
@@ -26,6 +26,17 @@ type WDelayerConstants struct {
|
|||||||
HermezRollup ethCommon.Address `json:"hermezRollup"`
|
HermezRollup ethCommon.Address `json:"hermezRollup"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WDelayerVariables are the variables of the Withdrawal Delayer Smart Contract
|
||||||
|
type WDelayerVariables struct {
|
||||||
|
HermezRollupAddress ethCommon.Address `json:"hermezRollupAddress" meddler:"rollup_address"`
|
||||||
|
HermezGovernanceDAOAddress ethCommon.Address `json:"hermezGovernanceDAOAddress" meddler:"govdao_address"`
|
||||||
|
WhiteHackGroupAddress ethCommon.Address `json:"whiteHackGroupAddress" meddler:"whg_address"`
|
||||||
|
HermezKeeperAddress ethCommon.Address `json:"hermezKeeperAddress" meddler:"keeper_address"`
|
||||||
|
WithdrawalDelay uint64 `json:"withdrawalDelay" meddler:"withdrawal_delay"`
|
||||||
|
EmergencyModeStartingTime uint64 `json:"emergencyModeStartingTime" meddler:"emergency_start_time"`
|
||||||
|
EmergencyMode bool `json:"emergencyMode" meddler:"emergency_mode"`
|
||||||
|
}
|
||||||
|
|
||||||
// DepositState is the state of Deposit
|
// DepositState is the state of Deposit
|
||||||
type DepositState struct {
|
type DepositState struct {
|
||||||
Amount *big.Int
|
Amount *big.Int
|
||||||
|
|||||||
Reference in New Issue
Block a user