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

Commit

Permalink
Release/v1.7.0 (#1140)
Browse files Browse the repository at this point in the history
* Backup old config file if exits

* Backup old config file if exits

* Ignore new config file if exits

* Avoid rewrite the service config file

* Use SuggestGasTipCap to get GasPrice

* Add base fee

* Fix typo

* Add log, fix typos

* Fix imports for linter

* Adjust log

* Add common.nonce package

* Fix nonce import in tests

* Fix imports

* Linter fixes

* Remove use of interface

* Linter fixes

* bump gin version (#1046)

* Reference endpoints with filter options (#1039)

Reference endpoints with filter options

* Turn the structs public

* Linter fixes

* Use 2 structures for Token

* Use 2 structures for Token

* Test if solve the stack overflow issue

* Fix types

* Revert marshal method

* Move api types to common, to avoid ciclic import error

* Fix structure types

* Fix types

* Add json tags to PoolL2TxAPI

* Turn the poolTxAPIView private

* Fix TxL2 name and refactor

* Update swagger

* Add nullable to field

* fixed verifyPoolL2Tx error (#1045)

* code owners (#998)

* code owners

* Suggestion

* suggestion

* suggestion

* Fix the use of multi proof servers

* Update example toml

* Adding new request for updating transactions in tx-pool (#1044)

* added on conflict condition to checkPoolIsFull

* added const to onConflictQuery var

* deleted rqfromidx test in txspool

* adding update for txs in the pool

* added correct test to atomicpool_test.go and additional fields to update for updateTx function

* fixed lint errors

* deleted checking for null in updateTx function

* added more tests for update txpool

* added info for transactions-pool put request in swagger.yml

* moved UpdateTxAPI function from l2db.go file to the apiqueries.go

* atomic: fix error message at invalid group

* Feature/update tx by idx and nonce (#1070)

* adding update transaction by idx and nonce function

* merged with develop

* Feature/#711 default config (#1037)

* Configuration

* ApiServer and logs fix

* Readme

* Config as library

* Config error messages

* Fix env variable names

* Fix paths in default config

* library name changed

* Readme improved

* fix array with env variables

* linter

* Default values and readme improved

* Adapt #1068 PR

* linter

* cfg not required

* Readme

* New lib version and env bug fixed

* test: remove debug log

* tests: remove unecessary comments

* Feature/tx selector sort txs by profitability (#1072)

* make tx selector to sort txs by profitability

* remove unused file

* trigger checks

* added guide to run integration tests (#1065)

* added guide to run integration tests

* added more info to guide

* fixed pr comments

* added possibility to update tx with invl status (#1075)

* txselector: use PR suggestion

Co-authored-by: a_bennassar <[email protected]>

* remove not necessary TODO messages (#1093)

* remove TODOs from code since we created issues to address them (#1094)

* Remove priceupdater (#1053)

* remove priceupdater

* remove update and create fiat

* remove config price updater

Co-authored-by: Marcelo Castellani <[email protected]>
Co-authored-by: Marcelo Castellani <[email protected]>
Co-authored-by: Mikhail Wall <[email protected]>
Co-authored-by: Alonso Rodriguez <[email protected]>
Co-authored-by: Mário Idival <[email protected]>
Co-authored-by: Thiago Coimbra Lemos <[email protected]>
  • Loading branch information
7 people authored Sep 13, 2021
1 parent b0e2400 commit 6048085
Show file tree
Hide file tree
Showing 75 changed files with 2,063 additions and 1,432 deletions.
32 changes: 24 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
*.md @jeffprestes
api/ @arnaubennassar
db/*.go @arnaubennassar
db/historydb @arnaubennassar
db/migrations @arnaubennassar
db/l2db @arnaubennassar
txselector/ @arnaubennassar
*.md @jeffprestes @arnaubennassar
api/ @Mikelle @ARR552
db/*.go @Mikelle @tclemos
db/historydb @Mikelle @tclemos
db/migrations @Mikelle @arnaubennassar
db/l2db @Mikelle @marioidival
db/kvdb @Mikelle @marioidival
db/statedb @Mikelle @marioidival
txselector/ @mfcastellani @tclemos @arnaubennassar
etherscan/ @ARR552
priceupdater/ @ARR552
priceupdater/ @marioidival @ARR552
common/ @Mikelle @mfcastellani
config/ @ARR552 @marioidival
coordinator/ @mfcastellani @marioidival
node/ @Mikelle @ARR552
eth/ @ARR552 @arnaubennassar
cmd/ @mfcastellani
txprocessor/ @mfcastellani @tclemos @arnaubennassar
health/ @Mikelle @ARR552
log/ @mfcastellani
metric/ @mfcastellani
test/ @arnaubennassar @mfcastellani
prover/ @mfcastellani @marioidival
synchronizer/ @ARR552 @arnaubennassar
batchbuilder/ @mfcastellani @marioidival
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,25 +187,28 @@ exec:
install:
echo " > Installing heznode as a service"
echo " > Checking requirements"
ifneq ("$(wildcard $(dist/heznode))","")
ifneq ("$(wildcard ./dist/heznode)","")
echo " - heznode file found!"
else
echo " - heznode file not found!"
echo " - please, run make build before make install!"
test -f ./dist/heznode
endif
ifneq ("$(wildcard $(cmd/heznode/cfg.builder.toml))","")
ifneq ("$(wildcard ./cmd/heznode/cfg.builder.toml)","")
echo " - config template found!"
else
echo " - config template not found!"
echo " - please, check the !"
echo " - please, check the ./cmd/heznode/cfg.builder.toml!"
test -f ./cmd/heznode/cfg.builder.toml
endif
echo " > Copying hez binary to /usr/local/bin"
cp dist/heznode /usr/local/bin/heznode
ifneq ("$(wildcard /etc/hermez/config.toml)","")
echo " > Config file already exists - ignored."
else
echo " > Copying config file to /etc/hermez"
mkdir -p /etc/hermez
cp cmd/heznode/cfg.builder.toml /etc/hermez/config.toml
endif
ifeq ("$(wildcard /etc/systemd/system/heznode.service)", "")
echo " > Registering as a service"
touch /etc/systemd/system/heznode.service
echo "[Unit]" | tee -a /etc/systemd/system/heznode.service > /dev/null
Expand All @@ -227,6 +230,13 @@ endif
echo "WantedBy=multi-user.target" | tee -a /etc/systemd/system/heznode.service > /dev/null
echo "" | tee -a /etc/systemd/system/heznode.service > /dev/null
systemctl daemon-reload
else
echo " > Service is already registered. Will be stoped!"
service heznode stop
rm /usr/local/bin/heznode
endif
echo " > Copying hez binary to /usr/local/bin"
cp dist/heznode /usr/local/bin/heznode
echo " > Service is ready. Please update the configs at /etc/hermez/config.toml"
echo " > You can use the service with service heznode status|start|stop"
echo " Bye."
3 changes: 0 additions & 3 deletions SETUP_NODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,6 @@ folder.
Is so that the API can be accessed by users outside the host.
- [ ] Add APIKey to `PriceUpdater.Fiat` section.
Get a key [here](https://exchangeratesapi.io/)
- [ ] Change PostgreSQL section with the values of user created before.
- HostWrite: Use the IP from server instead of localhost
Expand Down
5 changes: 3 additions & 2 deletions api/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"strconv"
"testing"

"github.com/hermeznetwork/hermez-node/api/apitypes"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/apitypes"
"github.com/hermeznetwork/hermez-node/common/nonce"
"github.com/hermeznetwork/hermez-node/db"
"github.com/hermeznetwork/hermez-node/db/historydb"
"github.com/mitchellh/copystructure"
Expand All @@ -20,7 +21,7 @@ type testAccount struct {
BatchNum common.BatchNum `json:"batchNum"`
PublicKey apitypes.HezBJJ `json:"bjj"`
EthAddr apitypes.HezEthAddr `json:"hezEthereumAddress"`
Nonce common.Nonce `json:"nonce"`
Nonce nonce.Nonce `json:"nonce"`
Balance *apitypes.BigIntStr `json:"balance"`
Token historydb.TokenWithUSD `json:"token"`
}
Expand Down
2 changes: 1 addition & 1 deletion api/accountcreationauths.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/gin-gonic/gin"
"github.com/hermeznetwork/hermez-node/api/apitypes"
"github.com/hermeznetwork/hermez-node/api/parsers"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/apitypes"
"github.com/iden3/go-iden3-crypto/babyjub"
)

Expand Down
4 changes: 3 additions & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ func NewAPI(
v1.GET("/account-creation-authorization/:hezEthereumAddress", a.getAccountCreationAuth)
// Transaction
v1.POST("/transactions-pool", a.postPoolTx)
v1.POST("/atomic-pool", a.postAtomicPool)
v1.PUT("/transactions-pool/:id", a.putPoolTx)
v1.PUT("/transactions-pool/accounts/:accountIndex/nonces/:nonce", a.putPoolTxByIdxAndNonce)
v1.GET("/transactions-pool/:id", a.getPoolTx)
v1.GET("/transactions-pool", a.getPoolTxs)
v1.POST("/atomic-pool", a.postAtomicPool)
v1.GET("/atomic-pool/:id", a.getAtomicGroup)
}

Expand Down
3 changes: 2 additions & 1 deletion api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/hermeznetwork/hermez-node/api/stateapiupdater"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/nonce"
"github.com/hermeznetwork/hermez-node/db"
"github.com/hermeznetwork/hermez-node/db/historydb"
"github.com/hermeznetwork/hermez-node/db/l2db"
Expand Down Expand Up @@ -361,7 +362,7 @@ func TestMain(m *testing.M) {
for _, batch := range block.Rollup.Batches {
commonL2Txs = append(commonL2Txs, batch.L2Txs...)
for i := range batch.CreatedAccounts {
batch.CreatedAccounts[i].Nonce = common.Nonce(i)
batch.CreatedAccounts[i].Nonce = nonce.Nonce(i)
commonAccounts = append(commonAccounts, batch.CreatedAccounts[i])
}
commonBatches = append(commonBatches, batch.Batch)
Expand Down
15 changes: 15 additions & 0 deletions api/atomicpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ func TestAtomicPool(t *testing.T) {
// Check txs in the DB
assertTxs(txsToReceive, atomicGroup.ID)

// test that we can't update atomic tx
// this test is checking, that this request will return error
// bcs of bad signature. Bad signature returned, bcs Rq* fields
// are part of the signature, but they are not part of json, which was sent
// we need to keep this test in case Rq* fields will be part of the PoolL2Tx json
txRepeated1 := atomicGroup.Txs[1]
jsonTxBytes, err = json.Marshal(txRepeated1)
require.NoError(t, err)
jsonTxReader = bytes.NewReader(jsonTxBytes)
fetchedTxID := common.TxID{}
require.Error(t, doGoodReq(
"PUT",
apiURL+"transactions-pool/"+txRepeated1.TxID.String(),
jsonTxReader, &fetchedTxID))

// Test only one tx with fee
// Generate txs
txs = []common.PoolL2Tx{}
Expand Down
2 changes: 1 addition & 1 deletion api/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"time"

ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/hermeznetwork/hermez-node/api/apitypes"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/apitypes"
"github.com/hermeznetwork/hermez-node/db"
"github.com/mitchellh/copystructure"
"github.com/stretchr/testify/assert"
Expand Down
5 changes: 5 additions & 0 deletions api/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ const (
// ErrFeeTooBigType type for fee too big error
ErrFeeTooBigType apiErrorType = "ErrFeeTooBig"

// ErrNothingToUpdateCode code for nothing to update error
ErrNothingToUpdateCode apiErrorCode = 25
// ErrNothingToUpdateType type for nothing to update type
ErrNothingToUpdateType apiErrorType = "ErrNothingToUpdate"

// ErrUnsupportedMaxNumBatch error message returned when tx.MaxNumBatch != 0 until the feature is fully implemented
ErrUnsupportedMaxNumBatch = "currently only supported value for maxNumBatch is 0, this will change soon when the feature is fully implemented"

Expand Down
2 changes: 1 addition & 1 deletion api/exits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hermeznetwork/hermez-node/api/apitypes"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/apitypes"
"github.com/hermeznetwork/hermez-node/db"
"github.com/hermeznetwork/hermez-node/db/historydb"
"github.com/mitchellh/copystructure"
Expand Down
5 changes: 4 additions & 1 deletion api/fiat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
)

func genFiatPrices(db *historydb.HistoryDB) error {
err := db.CreateFiatPrice("EUR", "USD", 0.82)
_, err := db.DB().Exec(
"INSERT INTO fiat(currency, base_currency, price) VALUES ($1, $2, $3);",
"EUR", "USD", 0.82,
)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions api/noroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestNoRouteVersionNotProvided(t *testing.T) {
resp, err := doSimpleReq("GET", endpoint)
assert.NoError(t, err)
assert.Equal(t,
"{\"error\":\"Version not provided, please provide a valid version in the path such as v1\"}\n",
"{\"error\":\"Version not provided, please provide a valid version in the path such as v1\"}",
resp)
}

Expand All @@ -24,6 +24,6 @@ func TestNoRoute(t *testing.T) {
resp, err := doSimpleReq("GET", endpoint)
assert.NoError(t, err)
assert.Equal(t,
"{\"error\":\"404 page not found\"}\n",
"{\"error\":\"404 page not found\"}",
resp)
}
22 changes: 22 additions & 0 deletions api/parsers/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/nonce"
"github.com/hermeznetwork/hermez-node/db/l2db"
"github.com/hermeznetwork/tracerr"
"gopkg.in/go-playground/validator.v9"
Expand All @@ -28,6 +29,27 @@ func ParsePoolTxFilter(c *gin.Context) (common.TxID, error) {
return txID, nil
}

// PoolTxUpdateByIdxAndNonceFilter struct to get uri param from /transactions-pool/accounts/:accountIndex/nonces/:nonce request
type PoolTxUpdateByIdxAndNonceFilter struct {
AccountIndex string `uri:"accountIndex" binding:"required"`
Nonce *uint `uri:"nonce" binding:"required"`
}

// ParsePoolTxUpdateByIdxAndNonceFilter func for parsing pool tx update by idx and nonce filter to the account index and nonce
func ParsePoolTxUpdateByIdxAndNonceFilter(c *gin.Context) (common.Idx, nonce.Nonce, error) {
var poolTxUpdateByIdxAndNonceFilter PoolTxUpdateByIdxAndNonceFilter
if err := c.ShouldBindUri(&poolTxUpdateByIdxAndNonceFilter); err != nil {
return common.Idx(0), 0, tracerr.Wrap(err)
}
queryAccount, err := common.StringToIdx(poolTxUpdateByIdxAndNonceFilter.AccountIndex, "accountIndex")
if err != nil {
return common.Idx(0), 0, tracerr.Wrap(err)
}

queryNonce := nonce.Nonce(*poolTxUpdateByIdxAndNonceFilter.Nonce)
return *queryAccount.AccountIndex, queryNonce, nil
}

// PoolTxsFilters struct for holding query params from /transactions-pool request
type PoolTxsFilters struct {
TokenID *uint `form:"tokenId"`
Expand Down
5 changes: 1 addition & 4 deletions api/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"math/big"
"testing"

"github.com/hermeznetwork/hermez-node/api/apitypes"
"github.com/hermeznetwork/hermez-node/common"
"github.com/hermeznetwork/hermez-node/common/apitypes"
"github.com/hermeznetwork/hermez-node/db/historydb"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -203,20 +203,17 @@ func TestGetState(t *testing.T) {
// Network
assert.Equal(t, lastBlock.Num, status.Network.LastEthBlock)
assert.Equal(t, lastBlock.Num, status.Network.LastSyncBlock)
// TODO: assert all the batch, not just the batch num
assert.Equal(t, lastBatchNum, status.Network.LastBatch.BatchNum)
assert.Equal(t, currentSlotNum, status.Network.CurrentSlot)
assertNextForgers(t, tc.nextForgers, status.Network.NextForgers)
// Metrics
// TODO: perform real asserts (not just greater than 0)
assert.Greater(t, status.Metrics.TransactionsPerBatch, float64(0))
assert.Greater(t, status.Metrics.BatchFrequency, float64(0))
assert.Greater(t, status.Metrics.TransactionsPerSecond, float64(0))
assert.Greater(t, status.Metrics.TokenAccounts, int64(0))
assert.Greater(t, status.Metrics.Wallets, int64(0))
assert.Greater(t, status.Metrics.AvgTransactionFee, float64(0))
// Recommended fee
// TODO: perform real asserts (not just greater than 0)
assert.Greater(t, status.RecommendedFee.ExistingAccount, float64(0))
assert.Equal(t, status.RecommendedFee.CreatesAccount,
status.RecommendedFee.ExistingAccount*
Expand Down
4 changes: 2 additions & 2 deletions api/stateapiupdater/stateapiupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Updater struct {

// RecommendedFeePolicy describes how the recommended fee is calculated
type RecommendedFeePolicy struct {
PolicyType RecommendedFeePolicyType `validate:"required"`
StaticValue float64
PolicyType RecommendedFeePolicyType `validate:"required" env:"HEZNODE_RECOMMENDEDFEEPOLICY_POLICYTYPE"`
StaticValue float64 `env:"HEZNODE_RECOMMENDEDFEEPOLICY_STATICVALUE"`
}

// RecommendedFeePolicyType describes the different available recommended fee strategies
Expand Down
Loading

0 comments on commit 6048085

Please sign in to comment.