arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
Merge pull request #675 from hermeznetwork/feature/configChainId

added chainId to config API
Danilo Pantani danpantani@gmail.com
Wed, 31 Mar 2021 12:39:39 -0300
commit

629c67a62e60cc912d4a15eced5271d956906893

parent

bb71a94e22a888b32791ac80b140d1ee6fc0208c

6 files changed, 10 insertions(+), 4 deletions(-)

jump to
M api/accountcreationauths.go → api/accountcreationauths.go

@@ -21,7 +21,7 @@ return

} // API to common + verify signature commonAuth := accountCreationAuthAPIToCommon(&apiAuth) - if !commonAuth.VerifySignature(a.chainID, a.hermezAddress) { + if !commonAuth.VerifySignature(a.cg.ChainID, a.hermezAddress) { retBadReq(errors.New("invalid signature"), c) return }
M api/api.go → api/api.go

@@ -40,7 +40,6 @@ type API struct {

h *historydb.HistoryDB cg *configAPI l2 *l2db.L2DB - chainID uint16 hermezAddress ethCommon.Address }

@@ -68,9 +67,9 @@ cg: &configAPI{

RollupConstants: *newRollupConstants(consts.Rollup), AuctionConstants: consts.Auction, WDelayerConstants: consts.WDelayer, + ChainID: consts.ChainID, }, l2: l2db, - chainID: consts.ChainID, hermezAddress: consts.HermezAddress, }
M api/api_test.go → api/api_test.go

@@ -215,6 +215,7 @@ // Config (smart contract constants)

chainID := uint16(0) _config := getConfigTest(chainID) config = configAPI{ + ChainID: chainID, RollupConstants: *newRollupConstants(_config.RollupConstants), AuctionConstants: _config.AuctionConstants, WDelayerConstants: _config.WDelayerConstants,
M api/config.go → api/config.go

@@ -57,6 +57,7 @@ HermezAddress ethCommon.Address

} type configAPI struct { + ChainID uint16 `json:"chainId"` RollupConstants rollupConstants `json:"hermez"` AuctionConstants common.AuctionConstants `json:"auction"` WDelayerConstants common.WDelayerConstants `json:"withdrawalDelayer"`
M api/swagger.yml → api/swagger.yml

@@ -3040,10 +3040,15 @@ - maxWithdrawalDelay

- maxEmergencyModeTime - hermezRollup additionalProperties: false + chainId: + type: integer + description: Id of the chain + example: 27 required: - hermez - auction - withdrawalDelayer + - chainId additionalProperties: false Error: type: object
M api/txspool.go → api/txspool.go

@@ -187,7 +187,7 @@ return tracerr.Wrap(fmt.Errorf("tx.TokenID (%v) != account.TokenID (%v)",

poolTx.TokenID, account.TokenID)) } // Check signature - if !poolTx.VerifySignature(a.chainID, account.BJJ) { + if !poolTx.VerifySignature(a.cg.ChainID, account.BJJ) { return tracerr.Wrap(errors.New("wrong signature")) } return nil