Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #845 from hermeznetwork/release/v1.3.0
Browse files Browse the repository at this point in the history
Release/v1.3.0
  • Loading branch information
arnaubennassar authored May 31, 2021
2 parents 1428af2 + 8b29e99 commit a577563
Show file tree
Hide file tree
Showing 31 changed files with 829 additions and 192 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Go implementation of the Hermez node.

## Developing

To contribute to this codebase you must follow the [branch model and development flow](council/gitflow.md).

### Go version

The `hermez-node` has been tested with go version 1.14
Expand Down
7 changes: 6 additions & 1 deletion api/accountcreationauths.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ func (a *API) postAccountCreationAuth(c *gin.Context) {
retSQLErr(err, c)
return
}
type okResponse struct {
Success string `json:"success"`
}
// Return OK
c.Status(http.StatusOK)
c.JSON(http.StatusOK, &okResponse{
Success: "OK",
})
}

func (a *API) getAccountCreationAuth(c *gin.Context) {
Expand Down
19 changes: 19 additions & 0 deletions api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ paths:
responses:
'200':
description: Successful operation.
content:
application/json:
schema:
$ref: '#/components/schemas/AccountCreationAuthorizationPostSuccessResponse'
'400':
description: Bad request.
content:
Expand Down Expand Up @@ -1786,6 +1790,16 @@ components:
- hezEthereumAddress
- bjj
- signature
AccountCreationAuthorizationPostSuccessResponse:
type: object
properties:
success:
type: string
example:
success: 'OK'
additionalProperties: false
required:
- success
HistoryTransaction:
type: object
description: Transaction of the Hermez Network
Expand Down Expand Up @@ -2207,6 +2221,10 @@ components:
type: string
description: hash of the Ethereum block in which the batch was forged
example: "0xfe88c94d860f01a17f961bf4bdfb6e0c6cd10d3fda5cc861e805ca1240c58553"
ethereumTxHash:
type: string
description: hash of the Ethereum transaction in which the batch was forged
example: "0xae98c94d860f01a17f961bf4bdfb6e0c6cd10d3fda5cc861e805ca1240c58553"
timestamp:
type: string
format: date-time
Expand Down Expand Up @@ -2247,6 +2265,7 @@ components:
required:
- itemId
- batchNum
- ethereumTxHash
- ethereumBlockNum
- ethereumBlockHash
- timestamp
Expand Down
2 changes: 1 addition & 1 deletion cmd/heznode/cfg.buidler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ LightScrypt = true

[Coordinator.Etherscan]
URL = "https://api.etherscan.io"
APIKey = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
APIKey = ""

[RecommendedFeePolicy]
# Strategy used to calculate the recommended fee that the API will expose.
Expand Down
78 changes: 70 additions & 8 deletions cmd/heznode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/hex"
"errors"
"fmt"
"os"
"os/signal"
Expand All @@ -25,13 +26,14 @@ import (
)

const (
flagCfg = "cfg"
flagMode = "mode"
flagSK = "privatekey"
flagYes = "yes"
flagBlock = "block"
modeSync = "sync"
modeCoord = "coord"
flagCfg = "cfg"
flagMode = "mode"
flagSK = "privatekey"
flagYes = "yes"
flagBlock = "block"
modeSync = "sync"
modeCoord = "coord"
nMigrations = "nMigrations"
)

var (
Expand Down Expand Up @@ -201,7 +203,7 @@ func cmdWipeDBs(c *cli.Context) error {
return tracerr.Wrap(err)
}
log.Info("Wiping SQL DB...")
if err := dbUtils.MigrationsDown(db.DB); err != nil {
if err := dbUtils.MigrationsDown(db.DB, 0); err != nil {
return tracerr.Wrap(fmt.Errorf("dbUtils.MigrationsDown: %w", err))
}

Expand All @@ -212,6 +214,48 @@ func cmdWipeDBs(c *cli.Context) error {
return nil
}

func cmdSQLMigrationDown(c *cli.Context) error {
_cfg, err := parseCli(c)
if err != nil {
return tracerr.Wrap(fmt.Errorf("error parsing flags and config: %w", err))
}
cfg := _cfg.node
yes := c.Bool(flagYes)
migrationsToRun := c.Uint(nMigrations)
if !yes {
fmt.Printf("*WARNING* Are you sure you want to revert "+
"%d the SQL migrations? [y/N]: ", migrationsToRun)
var input string
if _, err := fmt.Scanln(&input); err != nil {
return tracerr.Wrap(err)
}
input = strings.ToLower(input)
if !(input == "y" || input == "yes") {
return nil
}
}
if migrationsToRun == 0 {
return errors.New(nMigrations + "is set to 0, this is equivalent to use wipedbs command. If this is your intention use the other command")
}
db, err := dbUtils.ConnectSQLDB(
cfg.PostgreSQL.PortWrite,
cfg.PostgreSQL.HostWrite,
cfg.PostgreSQL.UserWrite,
cfg.PostgreSQL.PasswordWrite,
cfg.PostgreSQL.NameWrite,
)
if err != nil {
return tracerr.Wrap(err)
}
log.Infof("Reverting %d SQL migrations...", migrationsToRun)
if err := dbUtils.MigrationsDown(db.DB, migrationsToRun); err != nil {
return tracerr.Wrap(fmt.Errorf("dbUtils.MigrationsDown: %w", err))
}
log.Info("SQL migrations down successfully")

return nil
}

func waitSigInt() {
stopCh := make(chan interface{})

Expand Down Expand Up @@ -473,6 +517,24 @@ func main() {
Required: false,
}),
},
{
Name: "migratesqldown",
Aliases: []string{},
Usage: "Revert migrations of the SQL DB (HistoryDB and L2DB), " +
"leaving the SQL schema as in previous versions",
Action: cmdSQLMigrationDown,
Flags: append(flags,
&cli.BoolFlag{
Name: flagYes,
Usage: "automatic yes to the prompt",
Required: false,
},
&cli.UintFlag{
Name: nMigrations,
Usage: "amount of migrations to be reverted",
Required: true,
}),
},
{
Name: "run",
Aliases: []string{},
Expand Down
3 changes: 2 additions & 1 deletion common/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const batchNumBytesLen = 8

// Batch is a struct that represents Hermez network batch
type Batch struct {
BatchNum BatchNum `meddler:"batch_num"`
BatchNum BatchNum `meddler:"batch_num"`
EthTxHash ethCommon.Hash `meddler:"eth_tx_hash"`
// Ethereum block in which the batch is forged
EthBlockNum int64 `meddler:"eth_block_num"`
ForgerAddr ethCommon.Address `meddler:"forger_addr"`
Expand Down
4 changes: 2 additions & 2 deletions coordinator/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ type BatchInfo struct {
CoordIdxs []common.Idx
ForgeBatchArgs *eth.RollupForgeBatchArgs
Auth *bind.TransactOpts `json:"-"`
EthTx *types.Transaction
EthTxErr error
EthTxs []*types.Transaction
EthTxsErrs []error
// SendTimestamp the time of batch sent to ethereum
SendTimestamp time.Time
Receipt *types.Receipt
Expand Down
Loading

0 comments on commit a577563

Please sign in to comment.