diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 92f4d64e8..6fb5ad0ac 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,5 +4,6 @@ db/*.go @arnaubennassar db/historydb @arnaubennassar db/migrations @arnaubennassar db/l2db @arnaubennassar +txselector/ @arnaubennassar etherscan/ @ARR552 priceupdater/ @ARR552 diff --git a/.gitignore b/.gitignore index 8865f71b4..e68878870 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ dist/ .idea/ tmp/ .stamp.* +.vscode/ diff --git a/.goreleaser.yml b/.goreleaser.yml index ceb981cbc..a26ffe1fd 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -31,7 +31,7 @@ archives: - LICENSE - cmd/heznode/README.md - cmd/heznode/cfg.api.toml - - cmd/heznode/cfg.buidler.toml + - cmd/heznode/cfg.builder.toml checksum: name_template: 'checksums.txt' diff --git a/Makefile b/Makefile index 04cda4212..5e936a4c6 100644 --- a/Makefile +++ b/Makefile @@ -182,3 +182,51 @@ stop-database-container: ## exec: Run given command. e.g; make exec run="go test ./..." exec: $(GOENVVARS) $(run) + +## install: Install the heznode cli as a service in coord mode +install: + echo " > Installing heznode as a service" + echo " > Checking requirements" +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))","") + echo " - config template found!" +else + echo " - config template not found!" + echo " - please, check the !" + test -f ./cmd/heznode/cfg.builder.toml +endif + echo " > Copying hez binary to /usr/local/bin" + cp dist/heznode /usr/local/bin/heznode + echo " > Copying config file to /etc/hermez" + mkdir -p /etc/hermez + cp cmd/heznode/cfg.builder.toml /etc/hermez/config.toml + echo " > Registering as a service" + touch /etc/systemd/system/heznode.service + echo "[Unit]" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "Description=Hermez Node" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "After=postgresql.service" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "StartLimitBurst=5" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "StartLimitIntervalSec=60" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "[Service]" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "Type=simple" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "Restart=always" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "RestartSec=1" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "ExecStart=/usr/local/bin/heznode run --mode coord --cfg /etc/hermez/config.toml" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "KillMode=process" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "StandardOutput=append:/var/log/hermez-node.log" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "StandardError=append:/var/log/hermez-node.log" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "" | tee -a /etc/systemd/system/heznode.service > /dev/null + echo "[Install]" | tee -a /etc/systemd/system/heznode.service > /dev/null + 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 + 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." diff --git a/README.md b/README.md index ae5366c1b..fb5ed7d56 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ $ ./dist/heznode__amd64/heznode version ### Run -First you must edit the default/template config file into [cmd/heznode/cfg.buidler.toml](cmd/heznode/cfg.buidler.toml), +First you must edit the default/template config file into [cmd/heznode/cfg.buidler.toml](cmd/heznode/cfg.builder.toml), there are more information about the config file into [cmd/heznode/README.md](cmd/heznode/README.md) After setting the config, you can build and run the Hermez Node as a synchronizer: @@ -44,7 +44,7 @@ $ make run-node Or build and run as a coordinator, and also passing the config file from other location: ```shell -$ MODE=sync CONFIG=cmd/heznode/cfg.buidler.toml make run-node +$ MODE=sync CONFIG=cmd/heznode/cfg.builder.toml make run-node ``` To check the useful make commands: @@ -53,6 +53,33 @@ To check the useful make commands: $ make help ``` + +### Run as a service + +```shell +$ sudo make install +``` + +After, update the config file manually at `/etc/hermez/config.toml` + +```shell +$ sudo service heznode start +``` + +To check status + +```shell +$ sudo service heznode status +``` + +To stop + +```shell +$ sudo service heznode stop +``` + +If you just kill the process systemd will restart without asking. + ### Unit testing Running the unit tests requires a connection to a PostgreSQL database. You can diff --git a/SETUP_NODE.md b/SETUP_NODE.md new file mode 100644 index 000000000..174a44d33 --- /dev/null +++ b/SETUP_NODE.md @@ -0,0 +1,248 @@ +# Set up Hermez Nede + +This tutorial will help you to set up an Hermez Node and run as sync mode. + +## Golang + +- [ ] [Install](https://golang.org/doc/install#install) Golang +- [ ] [Create a](https://golang.org/doc/gopath_code#GOPATH) GOPATH environment +- [ ] Set GOPATH/bin into PATH machine + + ```command + export PATH=$PATH:$GOPATH/bin + ``` + +## Go-Ethereum + +- [ ] Clone [GETH](https://github.com/ethereum/go-ethereum) project and do a `make all` command into project folder. + - Need to have `gcc` on PATH. + + On Ubuntu/Debian you need install `build-essential` + + ```command + sudo apt-get update + sudo apt-get install build-essential + ``` + +- [ ] Add `build/bin` on PATH, after `make install` command inside of GETH +folder. + + ```command + export GETH_PATH=$GOPATH/src/github.com/ethereum/go-ethereum/ + export PATH=$PATH:$GETH_PATH/build/bin + ``` + +- [ ] Run the GETH + + Enter in a empty folder (really) and you can run: + + ```command + nohup geth --goerli --cache 4096 --http --http.addr INTERNAL_IP + --http.corsdomain *--http.vhosts* --http.api + "admin,eth,debug,miner,net,txpool,personal,web3" --ws --ws.addr INTERNAL_IP + --graphql --graphql.corsdomain *--graphql.vhosts* --vmdebug --metrics > + ~/temp/logs/geth-logs.log & + ``` + +- [ ] Wait the geth command finished to move to next step. + +## PostgreSQL + +- [ ] [Install](https://www.postgresql.org/download/) PostgreSQL +- [ ] Create a PostgreSQL User called `hermez` to project. + + ```command + createuser --interactive + ``` + +- [ ] Create a database + + ```command + createdb hermez-db + ``` + +- [ ] Create a password to `hermez` user created at step 2 + + ```command + ALTER USER hermez WITH PASSWORD 'Your#Password'; + ``` + +- [ ] Test connection on localhost with all steps made until now + + ```command + psql --host=localhost --dbname=hermez-db --username=hermez + ``` + +- [ ] If you need expose the database: + + In the `/etc/postgresql//main/postgresql.conf` file, change the value of `listen_address` to your host IP + + ```command + listen_address = "1.2.3.4" # + ``` + +## Nginx + +- [ ] [Install](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/) Nginx + +- [ ] We need create configuration file to Hermez Node with this content: + + File: + + ```command + /etc/nginx/conf.d/hermeznode.conf + ``` + + Content: + + ```txt + server { + listen 80; + listen [::]:80; + + server_name EXTERNAL_IP; + + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $http_host; + proxy_pass http://localhost:8086/; + } + } + ``` + + This Nginx configuration will help us to expose the Hermes as a node and sync mode, it can works just with external IP. + + For Hermes to run as coordinator mode, we need to set up a domain to the server. We do this in the next step. + +- [ ] Configure HTTPS + - [ ] Update the `hermeznode.conf` nginx file + + + Before of configure the file, you need have to a record of A type on DNS. + + ```txt + server { + listen 80; + listen [::]:80; + + server_name DOMAIN_NAME; + + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $http_host; + proxy_pass http://localhost:8086/; + } + } + ``` + + - [ ] Install the `certbot` + + On Debian/Ubuntu: + + ```command + apt update + apt install cerbot python3-certbot-nginx + sudo certbot --nginx + ``` + + You must awnser the wizard questions (from `certbot`) and waiting the update. + + The `hermeznde.conf` nginx file should look's like: + ```text + server { + listen 80; + listen [::]:80; + + server_name DOMAIN_NAME; + + location / { + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $http_host; + proxy_pass http://localhost:8086/; + } + + listen [::]:443 ssl ipv6only=on; # managed by Certbot + listen 443 ssl; # managed by Certbot + ssl_certificate /etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/DOMAIN_NAME/privkey.pem; # managed by Certbot + include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot + + } + server { + if ($host = DOMAIN_NAME) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + listen [::]:80; + + server_name DOMAIN_NAME; + return 404; # managed by Certbot + } + ``` + + +## Hermez-Node + +- [ ] Clone Hermez Node project and do a `make` command into project folder. + + ```command + git clone git@github.com:hermeznetwork/hermez-node.git $GOPATH/src/github.com/hermeznetwork/hermez-node + cd hermez-node + make + ``` + +- [ ] Add `dist` path generated after `make` command inside of Hermez Node +folder. + + ```command + export PATH=$PATH:$GOPATH/src/github.com/hermeznetwork/hermez-node/dist + ``` + +- [ ] Copy the config file from `cmd/heznode/cfg.builder.toml` to +`localconfig/cfg.builder.toml` and change some values: + - [ ] Use `0.0.0.0` instead of `localhost` to [API.Address] value + + 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 + + - [ ] Use the IP from host instead of localhost to [Web3.URL], the port is same. + Example: + + ```text + URL = "IP:8545" + ``` + + - [ ] In the [SmartContracts] section: + At Rollup, change to `0xf08a226B67a8A9f99cCfCF51c50867bc18a54F53`. + This is the address of Smart Contract used on Goerli. + - [ ] In the [Coordinator] section: + - At ForgerAddress, you need add the your wallet address. + - At ProofServerPollInterval, change to `3s`. + - At SyncRetryInterval, change to `2s`. + - At ForgeNoTxsDelay, change to `300s`. + - [ ] In the [Coordinator.FeeAccount] section + - At Address, you need add the your wallet address. + - [ ] In the [Coordinator.EthClient] section + - At MaxGasPrice, change to `12500000000000000000` + - [ ] In the [Coordinator.Etherscan] section + - Use this value to APIKey: `Insert an Etherscan key`. + +- [ ] Run the hermez-node as sync mode + + ```command + nohup heznode run --mode sync --cfg /home/youruser/go/src/github.com/hermeznetwork/hermez-node/localconfig/cfg.buidler.toml > ~/temp/logs/hermez-node.log 2>&1 & + ``` diff --git a/api/README.md b/api/README.md index 1fd34147b..748fcf476 100644 --- a/api/README.md +++ b/api/README.md @@ -13,7 +13,7 @@ To use a mock up of the endpoints in the API run `./run.sh doc` (UI + mock up se ## Editor -It is recomended to edit `swagger.yml` using a dedicated editor as they provide spec validation and real time visualization. Of course you can use your prefered editor. To use the editor run `./run.sh editor` and then [opening the editor in your browser](http://localhost:8002). +It is recommended to edit `swagger.yml` using a dedicated editor as they provide spec validation and real time visualization. Of course you can use your prefered editor. To use the editor run `./run.sh editor` and then [opening the editor in your browser](http://localhost:8002). **Keep in mind that you will need to manually save the file otherwise you will lose the changes** you made once you close your browser seshion or stop the server. **Note:** Your browser may cache the swagger definition, so in order to see updated changes it may be needed to refresh the page without cache (Ctrl + Shift + R). diff --git a/api/account.go b/api/account.go index 37a0d62ad..cfb19b163 100644 --- a/api/account.go +++ b/api/account.go @@ -11,17 +11,29 @@ import ( func (a *API) getAccount(c *gin.Context) { // Get Addr - idx, err := parsers.ParseAccountFilter(c) + account, err := parsers.ParseAccountFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } - apiAccount, err := a.h.GetAccountAPI(*idx) + apiAccount, err := a.h.GetAccountAPI(*account.AccountIndex) if err != nil { retSQLErr(err, c) return } - + //Check if symbol is correct + if apiAccount.TokenSymbol != account.Symbol { + retBadReq(&apiError{ + Err: fmt.Errorf("invalid token symbol"), + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) + return + } c.JSON(http.StatusOK, apiAccount) } @@ -29,14 +41,22 @@ func (a *API) getAccounts(c *gin.Context) { for id := range c.Request.URL.Query() { if id != "tokenIds" && id != "hezEthereumAddress" && id != "BJJ" && id != "fromItem" && id != "order" && id != "limit" { - retBadReq(fmt.Errorf("invalid Param: %s", id), c) + retBadReq(&apiError{ + Err: fmt.Errorf("invalid Param: %s", id), + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } } accountsFilter, err := parsers.ParseAccountsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } diff --git a/api/account_test.go b/api/account_test.go index 73bdc0af6..1ab9b8acd 100644 --- a/api/account_test.go +++ b/api/account_test.go @@ -158,6 +158,11 @@ func TestGetAccounts(t *testing.T) { account.Token.ItemID = 0 assert.Equal(t, fetchedAccounts[2], account) + // Test invalid token symbol GetAccount + path = fmt.Sprintf("%s/%s", endpoint, "hez:UNI:258") + account = testAccount{} + require.Error(t, doGoodReq("GET", path, nil, &account)) + // 400 path = fmt.Sprintf("%s/hez:12345", endpoint) err = doBadReq("GET", path, nil, 400) diff --git a/api/accountcreationauths.go b/api/accountcreationauths.go index b8415c587..8901aa91f 100644 --- a/api/accountcreationauths.go +++ b/api/accountcreationauths.go @@ -17,13 +17,21 @@ func (a *API) postAccountCreationAuth(c *gin.Context) { // Parse body var apiAuth receivedAuth if err := c.ShouldBindJSON(&apiAuth); err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType}, c) return } // API to common + verify signature commonAuth := accountCreationAuthAPIToCommon(&apiAuth) - if !commonAuth.VerifySignature(a.cg.ChainID, a.hermezAddress) { - retBadReq(errors.New("invalid signature"), c) + isValid, err := commonAuth.VerifySignature(a.cg.ChainID, a.hermezAddress) + if !isValid && err != nil { + retBadReq(&apiError{ + Err: errors.New("invalid signature: " + err.Error()), + Code: ErrInvalidSignatureCode, + Type: ErrInvalidSignatureType, + }, c) return } // Insert to DB @@ -44,7 +52,11 @@ func (a *API) getAccountCreationAuth(c *gin.Context) { // Get hezEthereumAddress addr, err := parsers.ParseGetAccountCreationAuthFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch auth from l2DB diff --git a/api/api.go b/api/api.go index 78c6ac5b9..10730e44d 100644 --- a/api/api.go +++ b/api/api.go @@ -35,6 +35,7 @@ import ( "github.com/hermeznetwork/hermez-node/api/parsers" "github.com/hermeznetwork/hermez-node/db/historydb" "github.com/hermeznetwork/hermez-node/db/l2db" + "github.com/hermeznetwork/hermez-node/db/statedb" "github.com/hermeznetwork/hermez-node/metric" "github.com/hermeznetwork/tracerr" "gopkg.in/go-playground/validator.v9" @@ -45,6 +46,7 @@ type API struct { h *historydb.HistoryDB cg *configAPI l2 *l2db.L2DB + stateDB *statedb.StateDB hermezAddress ethCommon.Address validate *validator.Validate } @@ -56,6 +58,7 @@ func NewAPI( server *gin.Engine, hdb *historydb.HistoryDB, l2db *l2db.L2DB, + stateDB *statedb.StateDB, ethClient *ethclient.Client, forgerAddress *ethCommon.Address, ) (*API, error) { @@ -80,6 +83,7 @@ func NewAPI( ChainID: consts.ChainID, }, l2: l2db, + stateDB: stateDB, hermezAddress: consts.HermezAddress, validate: newValidate(), } @@ -102,8 +106,10 @@ func NewAPI( v1.GET("/account-creation-authorization/:hezEthereumAddress", a.getAccountCreationAuth) // Transaction v1.POST("/transactions-pool", a.postPoolTx) + v1.POST("/atomic-pool", a.postAtomicPool) v1.GET("/transactions-pool/:id", a.getPoolTx) v1.GET("/transactions-pool", a.getPoolTxs) + v1.GET("/atomic-pool/:id", a.getAtomicGroup) } // Add explorer endpoints @@ -157,6 +163,7 @@ func newValidate() *validator.Validate { validate.RegisterStructValidation(parsers.AccountsFiltersStructValidation, parsers.AccountsFilters{}) validate.RegisterStructValidation(parsers.HistoryTxsFiltersStructValidation, parsers.HistoryTxsFilters{}) validate.RegisterStructValidation(parsers.PoolTxsTxsFiltersStructValidation, parsers.PoolTxsFilters{}) + validate.RegisterStructValidation(parsers.SlotsFiltersStructValidation, parsers.SlotsFilters{}) return validate } diff --git a/api/api_test.go b/api/api_test.go index 8e91c8bbd..4dad03478 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -177,7 +177,7 @@ type testCommon struct { accounts []testAccount txs []testTx exits []testExit - poolTxsToSend []testPoolTxSend + poolTxsToSend []common.PoolL2Tx poolTxsToReceive []testPoolTxReceive auths []testAuth router *swagger.Router @@ -212,7 +212,12 @@ func TestMain(m *testing.M) { panic(err) } // L2DB - l2DB := l2db.NewL2DB(database, database, 10, 1000, 0.0, 1000.0, 24*time.Hour, apiConnCon) + nodeConfig := &historydb.NodeConfig{ + MaxPoolTxs: 10, + MinFeeUSD: 0.000000000000001, + MaxFeeUSD: 10000000000, + } + l2DB := l2db.NewL2DB(database, database, 10, 1000, nodeConfig.MinFeeUSD, nodeConfig.MaxFeeUSD, 24*time.Hour, apiConnCon) test.WipeDB(l2DB.DB()) // this will clean HistoryDB and L2DB // Config (smart contract constants) chainID := uint16(0) @@ -241,11 +246,6 @@ func TestMain(m *testing.M) { if err := hdb.SetConstants(constants); err != nil { panic(err) } - nodeConfig := &historydb.NodeConfig{ - MaxPoolTxs: 10, - MinFeeUSD: 0, - MaxFeeUSD: 10000000000, - } if err := hdb.SetNodeConfig(nodeConfig); err != nil { panic(err) } @@ -259,6 +259,7 @@ func TestMain(m *testing.M) { l2DB, nil, nil, + nil, ) if err != nil { log.Error(err) @@ -295,7 +296,7 @@ func TestMain(m *testing.M) { if err != nil { panic(err) } - AddAditionalInformation(blocksData) + AddAdditionalInformation(blocksData) // Generate L2 Txs with til commonPoolTxs, err := tcc.GeneratePoolL2Txs(txsets.SetPoolL2MinimumFlow0) if err != nil { @@ -561,21 +562,21 @@ func TestMain(m *testing.M) { for i := 0; i < len(accounts); i++ { balance := new(big.Int) balance.SetString(string(*accounts[i].Balance), 10) - idx, err := common.StringToIdx(string(accounts[i].Idx), "foo") + queryAccount, err := common.StringToIdx(string(accounts[i].Idx), "foo") if err != nil { panic(err) } accUpdates = append(accUpdates, common.AccountUpdate{ EthBlockNum: 0, BatchNum: 1, - Idx: *idx, + Idx: *queryAccount.AccountIndex, Nonce: 0, Balance: balance, }) accUpdates = append(accUpdates, common.AccountUpdate{ EthBlockNum: 0, BatchNum: 1, - Idx: *idx, + Idx: *queryAccount.AccountIndex, Nonce: accounts[i].Nonce, Balance: balance, }) @@ -668,6 +669,7 @@ func TestTimeout(t *testing.T) { l2DBTO, nil, nil, + nil, ) require.NoError(t, err) @@ -820,6 +822,7 @@ func doBadReq(method, path string, reqBody io.Reader, expectedResponseCode int) ctx := context.Background() client := &http.Client{} httpReq, _ := http.NewRequest(method, path, reqBody) + httpReq.Header.Add("Content-Type", "application/json") route, pathParams, err := tc.router.FindRoute(httpReq.Method, httpReq.URL) if err != nil { return tracerr.Wrap(err) diff --git a/api/atomicpool.go b/api/atomicpool.go new file mode 100644 index 000000000..2824e5fb4 --- /dev/null +++ b/api/atomicpool.go @@ -0,0 +1,192 @@ +package api + +import ( + "errors" + "net/http" + + "github.com/gin-gonic/gin" + "github.com/hermeznetwork/hermez-node/api/parsers" + "github.com/hermeznetwork/hermez-node/common" + "github.com/yourbasic/graph" +) + +func (a *API) postAtomicPool(c *gin.Context) { + // Parse body + var receivedAtomicGroup common.AtomicGroup + if err := c.ShouldBindJSON(&receivedAtomicGroup); err != nil { + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) + return + } + // Validate atomic group id + if !receivedAtomicGroup.IsAtomicGroupIDValid() { + retBadReq(&apiError{ + Err: errors.New(ErrInvalidAtomicGroupID), + Code: ErrInvalidAtomicGroupIDCode, + Type: ErrInvalidAtomicGroupIDType, + }, c) + return + } + nTxs := len(receivedAtomicGroup.Txs) + if nTxs <= 1 { + retBadReq(&apiError{ + Err: errors.New(ErrSingleTxInAtomicEndpoint), + Code: ErrSingleTxInAtomicEndpointCode, + Type: ErrSingleTxInAtomicEndpointType, + }, c) + return + } + // Validate txs + txIDStrings := make([]string, nTxs) // used for successful response + clientIP := c.ClientIP() + for i, tx := range receivedAtomicGroup.Txs { + // Find requested transaction + relativePosition, err := RequestOffset2RelativePosition(tx.RqOffset) + if err != nil { + retBadReq(&apiError{ + Err: err, + Code: ErrFailedToFindOffsetToRelativePositionCode, + Type: ErrFailedToFindOffsetToRelativePositionType, + }, c) + return + } + requestedPosition := i + relativePosition + if requestedPosition > len(receivedAtomicGroup.Txs)-1 || requestedPosition < 0 { + retBadReq(&apiError{ + Err: errors.New(ErrRqOffsetOutOfBounds), + Code: ErrRqOffsetOutOfBoundsCode, + Type: ErrRqOffsetOutOfBoundsType, + }, c) + return + } + // Set fields that are omitted in the JSON + requestedTx := receivedAtomicGroup.Txs[requestedPosition] + receivedAtomicGroup.Txs[i].RqFromIdx = requestedTx.FromIdx + receivedAtomicGroup.Txs[i].RqToIdx = requestedTx.ToIdx + receivedAtomicGroup.Txs[i].RqToEthAddr = requestedTx.ToEthAddr + receivedAtomicGroup.Txs[i].RqToBJJ = requestedTx.ToBJJ + receivedAtomicGroup.Txs[i].RqTokenID = requestedTx.TokenID + receivedAtomicGroup.Txs[i].RqAmount = requestedTx.Amount + receivedAtomicGroup.Txs[i].RqFee = requestedTx.Fee + receivedAtomicGroup.Txs[i].RqNonce = requestedTx.Nonce + receivedAtomicGroup.Txs[i].ClientIP = clientIP + receivedAtomicGroup.Txs[i].AtomicGroupID = receivedAtomicGroup.ID + receivedAtomicGroup.Txs[i].Info = "" + + // Validate transaction + if err := a.verifyPoolL2Tx(receivedAtomicGroup.Txs[i]); err != nil { + retBadReq(err, c) + return + } + + // Prepare response + txIDStrings[i] = receivedAtomicGroup.Txs[i].TxID.String() + } + + // Validate that all txs in the payload represent a single atomic group + if !isSingleAtomicGroup(receivedAtomicGroup.Txs) { + retBadReq(&apiError{ + Err: errors.New(ErrTxsNotAtomic), + Code: ErrTxsNotAtomicCode, + Type: ErrTxsNotAtomicType, + }, c) + return + } + // Insert to DB + if err := a.l2.AddAtomicTxsAPI(receivedAtomicGroup.Txs); err != nil { + retSQLErr(err, c) + return + } + // Return IDs of the added txs in the pool + c.JSON(http.StatusOK, txIDStrings) +} + +// RequestOffset2RelativePosition translates from 0 to 7 to protocol position +func RequestOffset2RelativePosition(rqoffset uint8) (int, error) { + const ( + rqOffsetZero = 0 + rqOffsetOne = 1 + rqOffsetTwo = 2 + rqOffsetThree = 3 + rqOffsetFour = 4 + rqOffsetFive = 5 + rqOffsetSix = 6 + rqOffsetSeven = 7 + rqOffsetMinusFour = -4 + rqOffsetMinusThree = -3 + rqOffsetMinusTwo = -2 + rqOffsetMinusOne = -1 + ) + + switch rqoffset { + case rqOffsetZero: + return rqOffsetZero, errors.New(ErrTxsNotAtomic) + case rqOffsetOne: + return rqOffsetOne, nil + case rqOffsetTwo: + return rqOffsetTwo, nil + case rqOffsetThree: + return rqOffsetThree, nil + case rqOffsetFour: + return rqOffsetMinusFour, nil + case rqOffsetFive: + return rqOffsetMinusThree, nil + case rqOffsetSix: + return rqOffsetMinusTwo, nil + case rqOffsetSeven: + return rqOffsetMinusOne, nil + default: + return rqOffsetZero, errors.New(ErrInvalidRqOffset) + } +} + +// isSingleAtomicGroup returns true if all the txs are needed to be forged +// (all txs will be forged in the same batch or non of them will be forged) +func isSingleAtomicGroup(txs []common.PoolL2Tx) bool { + // Create a graph from the given txs to represent requests between transactions + g := graph.New(len(txs)) + // Create vertices that connect nodes of the graph (txs) using RqOffset + for i, tx := range txs { + requestedRelativePosition, err := RequestOffset2RelativePosition(tx.RqOffset) + if err != nil { + return false + } + requestedPosition := i + requestedRelativePosition + if requestedPosition < 0 || requestedPosition >= len(txs) { + // Safety check: requested tx is not out of array bounds + return false + } + g.Add(i, requestedPosition) + } + // A graph with a single strongly connected component, + // means that all the nodes can be reached from all the nodes. + // If tx A "can reach" tx B it means that tx A requests tx B. + // Therefore we can say that if there is a single strongly connected component in the graph, + // all the transactions require all trnsactions to be forged, in other words: they are an atomic group + strongComponents := graph.StrongComponents(g) + return len(strongComponents) == 1 +} + +func (a *API) getAtomicGroup(c *gin.Context) { + // Get TxID + atomicGroupID, err := parsers.ParseParamAtomicGroupID(c) + if err != nil { + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) + return + } + // Fetch tx from l2DB + txs, err := a.l2.GetPoolTxsByAtomicGroupIDAPI(atomicGroupID) + if err != nil { + retSQLErr(err, c) + return + } + // Build successful response + c.JSON(http.StatusOK, txs) +} diff --git a/api/atomicpool_test.go b/api/atomicpool_test.go new file mode 100644 index 000000000..277f2884c --- /dev/null +++ b/api/atomicpool_test.go @@ -0,0 +1,373 @@ +package api + +import ( + "bytes" + "crypto/ecdsa" + "encoding/binary" + "encoding/json" + "fmt" + "math/big" + "testing" + + ethCommon "github.com/ethereum/go-ethereum/common" + ethCrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/hermeznetwork/hermez-node/common" + "github.com/hermeznetwork/hermez-node/db/historydb" + "github.com/iden3/go-iden3-crypto/babyjub" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestAtomicPool(t *testing.T) { + // Generate N "wallets" (account + private key) + const nAccounts = 4 // don't change this value + const usedToken = 0 // this test will use only a token + accounts := make([]common.Account, nAccounts) + accountUpdates := make([]common.AccountUpdate, nAccounts) + privateKeys := make(map[common.Idx]*babyjub.PrivateKey, nAccounts) + for i := 0; i < nAccounts; i++ { + addr, privKey := generateKeys(i + 1234567) + idx := common.Idx(i) + 5000 + account := common.Account{ + Idx: idx, + TokenID: tc.tokens[usedToken].TokenID, + BatchNum: 1, + BJJ: privKey.Public().Compress(), + EthAddr: addr, + } + balance, ok := big.NewInt(0).SetString("1000000000000000000", 10) + require.True(t, ok) + accountUpdate := common.AccountUpdate{ + Idx: idx, + BatchNum: 1, + Nonce: 0, + Balance: balance, + } + accounts[i] = account + accountUpdates[i] = accountUpdate + privateKeys[idx] = &privKey + } + // Add accounts to HistoryDB + err := api.h.AddAccounts(accounts) + assert.NoError(t, err) + err = api.h.AddAccountUpdates(accountUpdates) + assert.NoError(t, err) + + txsToClean := []common.TxID{} + signAndTransformTxs := func(txs []common.PoolL2Tx) (common.AtomicGroup, []testPoolTxReceive) { + for i := 0; i < len(txs); i++ { + // Set TxID and type + _, err := common.NewPoolL2Tx(&txs[i]) + txsToClean = append(txsToClean, txs[i].TxID) + assert.NoError(t, err) + // Sign + toSign, err := txs[i].HashToSign(0) + assert.NoError(t, err) + sig := privateKeys[txs[i].FromIdx].SignPoseidon(toSign) + txs[i].Signature = sig.Compress() + } + txsToSend, txsToReceive := genTestPoolTxs(txs, []historydb.TokenWithUSD{tc.tokens[usedToken]}, accounts) + atomicGroup := common.AtomicGroup{Txs: txsToSend} + atomicGroup.SetAtomicGroupID() + return atomicGroup, txsToReceive + } + assertTxs := func(txsToReceive []testPoolTxReceive, atomicGroupID common.AtomicGroupID) { + // Fetch txs one by one + for _, tx := range txsToReceive { + const path = apiURL + "transactions-pool/" + fetchedTx := testPoolTxReceive{} + require.NoError( + t, doGoodReq( + "GET", + path+tx.TxID.String(), + nil, &fetchedTx, + ), + ) + assertPoolTx(t, tx, fetchedTx) + } + // Fetch all the group using GET /atomic-pool/{id} + const path = apiURL + "atomic-pool/" + fetchedTxs := []testPoolTxReceive{} + require.NoError( + t, doGoodReq( + "GET", + path+atomicGroupID.String(), + nil, &fetchedTxs, + ), + ) + assert.Equal(t, len(txsToReceive), len(fetchedTxs)) + for i, tx := range txsToReceive { + assertPoolTx(t, tx, fetchedTxs[i]) + } + } + + const path = apiURL + "atomic-pool" + // Test correct atomic group (ciclic) + /* + A ──────────► B + ▲ │ + │ │ + └────── C ◄────┘ + */ + // Generate txs + txs := []common.PoolL2Tx{} + baseTx := common.PoolL2Tx{ + TokenID: tc.tokens[usedToken].TokenID, + Amount: big.NewInt(10000000000), + Fee: 200, + Nonce: 0, + RqTokenID: tc.tokens[usedToken].TokenID, + RqAmount: big.NewInt(10000000000), + RqFee: 200, + RqNonce: 0, + MaxNumBatch: 9999999, + } + for i := 0; i < nAccounts; i++ { + tx := baseTx + tx.FromIdx = accounts[i].Idx + tx.ToIdx = accounts[(i+1)%nAccounts].Idx + tx.RqFromIdx = accounts[(i+1)%nAccounts].Idx + tx.RqToIdx = accounts[(i+2)%nAccounts].Idx + if i != nAccounts-1 { + tx.RqOffset = 1 + } else { + tx.RqOffset = 5 + } + txs = append(txs, tx) + } + // Sign and format txs + atomicGroup, txsToReceive := signAndTransformTxs(txs) + // Send txs + jsonTxBytes, err := json.Marshal(atomicGroup) + require.NoError(t, err) + jsonTxReader := bytes.NewReader(jsonTxBytes) + fetchedTxIDs := []common.TxID{} + err = doGoodReq("POST", path, jsonTxReader, &fetchedTxIDs) + assert.NoError(t, err) + // Check response + expectedTxIDs := []common.TxID{} + for _, tx := range txs { + expectedTxIDs = append(expectedTxIDs, tx.TxID) + } + assert.Equal(t, expectedTxIDs, fetchedTxIDs) + // Check txs in the DB + assertTxs(txsToReceive, atomicGroup.ID) + + // Test only one tx with fee + // Generate txs + txs = []common.PoolL2Tx{} + baseTx.Nonce = 1 + baseTx.RqNonce = 1 // Nonce incremented just to avoid TxID conflicts + baseTx.Fee = 0 + baseTx.RqFee = 0 + for i := 0; i < nAccounts; i++ { + tx := baseTx + tx.FromIdx = accounts[i].Idx + tx.ToIdx = accounts[(i+1)%nAccounts].Idx + tx.RqFromIdx = accounts[(i+1)%nAccounts].Idx + tx.RqToIdx = accounts[(i+2)%nAccounts].Idx + if i == 0 { + tx.Fee = 200 + } else if i == nAccounts-1 { + tx.RqFee = 200 + } + if i != nAccounts-1 { + tx.RqOffset = 1 + } else { + tx.RqOffset = 5 + } + txs = append(txs, tx) + } + // Sign and format txs + atomicGroup, txsToReceive = signAndTransformTxs(txs) + // Send txs + jsonTxBytes, err = json.Marshal(atomicGroup) + require.NoError(t, err) + jsonTxReader = bytes.NewReader(jsonTxBytes) + fetchedTxIDs = []common.TxID{} + err = doGoodReq("POST", path, jsonTxReader, &fetchedTxIDs) + assert.NoError(t, err) + // Check response + expectedTxIDs = []common.TxID{} + for _, tx := range txs { + expectedTxIDs = append(expectedTxIDs, tx.TxID) + } + assert.Equal(t, expectedTxIDs, fetchedTxIDs) + // Check txs in the DB + assertTxs(txsToReceive, atomicGroup.ID) + + // Test wrong atomic group id + txs = []common.PoolL2Tx{} + baseTx.Nonce = 2 + baseTx.RqNonce = 2 // Nonce incremented just to avoid TxID conflicts + for i := 0; i < nAccounts; i++ { + tx := baseTx + tx.FromIdx = accounts[i].Idx + tx.ToIdx = accounts[(i+1)%nAccounts].Idx + tx.RqFromIdx = accounts[(i+1)%nAccounts].Idx + tx.RqToIdx = accounts[(i+2)%nAccounts].Idx + if i == 0 { + tx.Fee = 5 + tx.RqOffset = 1 + } else if i == nAccounts-1 { + tx.RqFee = 5 + tx.RqOffset = 5 + } + txs = append(txs, tx) + } + // Sign and format txs + atomicGroup, _ = signAndTransformTxs(txs) + atomicGroup.ID = common.AtomicGroupID([32]byte{1, 2, 3, 4}) + // Send txs + jsonTxBytes, err = json.Marshal(atomicGroup) + require.NoError(t, err) + jsonTxReader = bytes.NewReader(jsonTxBytes) + err = doBadReq("POST", path, jsonTxReader, 400) + assert.NoError(t, err) + + // Test fee too low + // Generate txs + txs = []common.PoolL2Tx{} + baseTx.Nonce = 3 + baseTx.RqNonce = 3 // Nonce incremented just to avoid TxID conflicts + baseTx.Fee = 0 + baseTx.RqFee = 0 + for i := 0; i < nAccounts; i++ { + tx := baseTx + tx.FromIdx = accounts[i].Idx + tx.ToIdx = accounts[(i+1)%nAccounts].Idx + tx.RqFromIdx = accounts[(i+1)%nAccounts].Idx + tx.RqToIdx = accounts[(i+2)%nAccounts].Idx + if i == 0 { + tx.Fee = 5 + tx.RqOffset = 1 + } else if i == nAccounts-1 { + tx.RqFee = 5 + tx.RqOffset = 5 + } + txs = append(txs, tx) + } + // Sign and format txs + atomicGroup, _ = signAndTransformTxs(txs) + // Send txs + jsonTxBytes, err = json.Marshal(atomicGroup) + require.NoError(t, err) + jsonTxReader = bytes.NewReader(jsonTxBytes) + err = doBadReq("POST", path, jsonTxReader, 400) + assert.NoError(t, err) + + // Test group that is not atomic #1 + /* Note that in this example, txs B and C could be forged without A + + A ──────────► B ───────► C + ▲ │ + └──────────┘ + */ + // Generate txs + txs = []common.PoolL2Tx{} + // Acyclic part: A ──────────► B + A := baseTx + A.FromIdx = accounts[nAccounts-1].Idx + A.ToIdx = accounts[0].Idx + A.RqFromIdx = accounts[0].Idx + A.RqToIdx = accounts[1].Idx + A.RqOffset = 1 + txs = append(txs, A) + /* Cyclic part: + B ───────► C + ▲ │ + └──────────┘ + */ + nAccountsMinus1 := nAccounts - 1 + for i := 0; i < nAccountsMinus1; i++ { + tx := baseTx + tx.FromIdx = accounts[i].Idx + tx.ToIdx = accounts[(i+1)%nAccountsMinus1].Idx + tx.RqFromIdx = accounts[(i+1)%nAccountsMinus1].Idx + tx.RqToIdx = accounts[(i+2)%nAccountsMinus1].Idx + if i != nAccountsMinus1-1 { + tx.RqOffset = 1 + } else { + tx.RqOffset = 6 + } + txs = append(txs, tx) + } + // Sign and format txs + atomicGroup, _ = signAndTransformTxs(txs) + // Send txs + jsonTxBytes, err = json.Marshal(atomicGroup) + require.NoError(t, err) + jsonTxReader = bytes.NewReader(jsonTxBytes) + err = doBadReq("POST", path, jsonTxReader, 400) + assert.NoError(t, err) + + // Clean historyDB: the added account shouldn't be there for other tests + for _, account := range accounts { + _, err := api.h.DB().DB.Exec( + fmt.Sprintf("delete from account where idx = %d;", account.Idx), + ) + assert.NoError(t, err) + } + // clean l2DB: the added txs shouldn't be there for other tests + for _, txID := range txsToClean { + _, err := api.h.DB().DB.Exec("delete from tx_pool where tx_id = $1;", txID) + assert.NoError(t, err) + } +} + +func generateKeys(random int) (ethCommon.Address, babyjub.PrivateKey) { + var key ecdsa.PrivateKey + key.D = big.NewInt(int64(random)) // only for testing + key.PublicKey.X, key.PublicKey.Y = ethCrypto.S256().ScalarBaseMult(key.D.Bytes()) + key.Curve = ethCrypto.S256() + addr := ethCrypto.PubkeyToAddress(key.PublicKey) + // BJJ private key + var sk babyjub.PrivateKey + var iBytes [8]byte + binary.LittleEndian.PutUint64(iBytes[:], uint64(random)) + copy(sk[:], iBytes[:]) // only for testing + return addr, sk +} + +func TestIsAtomic(t *testing.T) { + // NOT atomic cases + // Empty group + txs := []common.PoolL2Tx{} + assert.False(t, isSingleAtomicGroup(txs)) + + // Case missing tx: 1 ==> 2 ==> 3 ==> (4: not provided) + txs = []common.PoolL2Tx{ + {TxID: common.TxID{1}, RqOffset: 1}, + {TxID: common.TxID{2}, RqOffset: 1}, + {TxID: common.TxID{3}, RqOffset: 1}, + } + assert.False(t, isSingleAtomicGroup(txs)) + + // Case loneley tx: 1 ==> 2 ==> 3 ==> 1 <== (4: no buddy references 4th tx) + txs = []common.PoolL2Tx{ + {TxID: common.TxID{1}, RqOffset: 1}, + {TxID: common.TxID{2}, RqOffset: 1}, + {TxID: common.TxID{3}, RqOffset: 6}, // 6 represents -2 + {TxID: common.TxID{4}, RqOffset: 5}, // 5 represents -3 + } + assert.False(t, isSingleAtomicGroup(txs)) + + // Case two groups: 1 <==> 2 3 <==> 4 + txs = []common.PoolL2Tx{ + {TxID: common.TxID{1}, RqOffset: 1}, + {TxID: common.TxID{2}, RqOffset: 7}, // 7 represents -1 + {TxID: common.TxID{3}, RqOffset: 1}, + {TxID: common.TxID{4}, RqOffset: 7}, // 7 represents -1 + } + assert.False(t, isSingleAtomicGroup(txs)) + + // Atomic cases + // Case circular: 1 ==> 2 ==> 3 ==> 4 ==> 1 + txs = []common.PoolL2Tx{ + {TxID: common.TxID{1}, RqOffset: 1}, + {TxID: common.TxID{2}, RqOffset: 1}, + {TxID: common.TxID{3}, RqOffset: 1}, + {TxID: common.TxID{4}, RqOffset: 5}, // 5 represents -3 + } + assert.True(t, isSingleAtomicGroup(txs)) +} diff --git a/api/aux_test.go b/api/aux_test.go index eea6f401b..f76f91395 100644 --- a/api/aux_test.go +++ b/api/aux_test.go @@ -10,7 +10,7 @@ import ( "github.com/iden3/go-merkletree" ) -func AddAditionalInformation(blocks []common.BlockData) { +func AddAdditionalInformation(blocks []common.BlockData) { for i := range blocks { blocks[i].Block.Timestamp = time.Now().Add(time.Second * 13).UTC() blocks[i].Block.Hash = ethCommon.BigToHash(big.NewInt(blocks[i].Block.Num)) diff --git a/api/batch.go b/api/batch.go index 5f35a4abc..e8f08c02f 100644 --- a/api/batch.go +++ b/api/batch.go @@ -16,7 +16,11 @@ func (a *API) getBatches(c *gin.Context) { // Get query parameters filter, err := parsers.ParseBatchesFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch batches from historyDB @@ -41,7 +45,11 @@ func (a *API) getBatch(c *gin.Context) { // Get batchNum batchNum, err := parsers.ParseBatchFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch batch from historyDB @@ -63,7 +71,11 @@ func (a *API) getFullBatch(c *gin.Context) { // Get batchNum batchNum, err := parsers.ParseBatchFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch batch from historyDB diff --git a/api/bids.go b/api/bids.go index 25e1f5945..250487d34 100644 --- a/api/bids.go +++ b/api/bids.go @@ -11,7 +11,11 @@ import ( func (a *API) getBids(c *gin.Context) { filters, err := parsers.ParseBidsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } diff --git a/api/coordinator.go b/api/coordinator.go index 261528d16..0e7044434 100644 --- a/api/coordinator.go +++ b/api/coordinator.go @@ -11,7 +11,11 @@ import ( func (a *API) getCoordinators(c *gin.Context) { filters, err := parsers.ParseCoordinatorsFilters(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } diff --git a/api/errors.go b/api/errors.go index 76b4b53f1..beac53e50 100644 --- a/api/errors.go +++ b/api/errors.go @@ -1,23 +1,173 @@ package api +type apiErrorCode uint +type apiErrorType string + const ( // Public error messages (included in response objects) + // ErrParamValidationFailedCode code for param validation failed error + ErrParamValidationFailedCode apiErrorCode = 1 + // ErrParamValidationFailedType type for param validation failed error + ErrParamValidationFailedType apiErrorType = "ErrParamValidationFailed" + // ErrDuplicatedKey error message returned when trying to insert an item with duplicated key ErrDuplicatedKey = "Item already exists" + // ErrDuplicatedKeyCode code for duplicated key error + ErrDuplicatedKeyCode apiErrorCode = 2 + // ErrDuplicatedKeyType type for duplicated key error + ErrDuplicatedKeyType apiErrorType = "ErrDuplicatedKey" + // ErrSQLTimeout error message returned when timeout due to SQL connection - ErrSQLTimeout = "The node is under heavy preasure, please try again later" - // ErrExitAmount0 error message returned when receiving (and rejecting) a tr of type exit with amount 0 + ErrSQLTimeout = "The node is under heavy pressure, please try again later" + // ErrSQLTimeoutCode code for sql timeout error + ErrSQLTimeoutCode apiErrorCode = 3 + // ErrSQLTimeoutType type for sql timeout type + ErrSQLTimeoutType apiErrorType = "ErrSQLTimeout" + + // ErrSQLNoRows error message returned when there is no such records + ErrSQLNoRows = "record(s) were not found for this query and/or the parameters entered" + // ErrSQLNoRowsCode code for no rows error + ErrSQLNoRowsCode apiErrorCode = 4 + // ErrSQLNoRowsType type for now rows error + ErrSQLNoRowsType apiErrorType = "ErrSQLNoRows" + + // ErrExitAmount0 error message returned when receiving (and rejecting) a tx of type exit with amount 0 ErrExitAmount0 = "Transaction rejected because an exit with amount 0 has no sense" + // ErrExitAmount0Code code for 0 exit amount error + ErrExitAmount0Code apiErrorCode = 5 + // ErrExitAmount0Type type for 0 exit amount error + ErrExitAmount0Type apiErrorType = "ErrExitAmount0" + + // ErrInvalidTxTypeOrTxIDCode code for invalid tx type or txID error + ErrInvalidTxTypeOrTxIDCode apiErrorCode = 6 + // ErrInvalidTxTypeOrTxIDType type for invalid tx type or txID error + ErrInvalidTxTypeOrTxIDType apiErrorType = "ErrInvalidTxTypeOrTxID" + + // ErrFeeOverflowCode code for fee overflow code error + ErrFeeOverflowCode apiErrorCode = 7 + // ErrFeeOverflowType type for fee overflow code type + ErrFeeOverflowType apiErrorType = "ErrFeeOverflow" + + // ErrGettingSenderAccountCode code for getting sender account error + ErrGettingSenderAccountCode apiErrorCode = 8 + // ErrGettingSenderAccountType type for getting sender account error + ErrGettingSenderAccountType apiErrorType = "ErrGettingSenderAccount" + + // ErrAccountTokenNotEqualTxTokenCode code for account token not equal tx token error + ErrAccountTokenNotEqualTxTokenCode apiErrorCode = 9 + // ErrAccountTokenNotEqualTxTokenType type for account token not equal tx token type + ErrAccountTokenNotEqualTxTokenType apiErrorType = "ErrAccountTokenNotEqualTxToken" + + // ErrInvalidNonceCode code for invalid nonce error + ErrInvalidNonceCode apiErrorCode = 10 + // ErrInvalidNonceType type for invalid nonce error + ErrInvalidNonceType apiErrorType = "ErrInvalidNonce" + + // ErrInvalidSignatureCode code for invalid signature error + ErrInvalidSignatureCode apiErrorCode = 11 + // ErrInvalidSignatureType type for invalid signature error + ErrInvalidSignatureType apiErrorType = "ErrInvalidSignature" + + // ErrGettingReceiverAccountCode code for getting receiver account error + ErrGettingReceiverAccountCode apiErrorCode = 12 + // ErrGettingReceiverAccountType type for getting receiver account error + ErrGettingReceiverAccountType apiErrorType = "ErrGettingReceiverAccount" + + // ErrCantSendToEthAddrCode code when can't send to eth addr code error appeared + ErrCantSendToEthAddrCode apiErrorCode = 13 + // ErrCantSendToEthAddrType type when can't send to eth addr code error appeared + ErrCantSendToEthAddrType apiErrorType = "ErrCantSendToEthAddr" + + // ErrNotAtomicTxsInPostPoolTx error message returned when received an non-atomic transaction inside atomic pool + ErrNotAtomicTxsInPostPoolTx = "atomic transactions are only accepted in POST /atomic-pool" + // ErrNotAtomicTxsInPostPoolTxCode code filter atomic transactions on POST /transactions-pool + ErrNotAtomicTxsInPostPoolTxCode apiErrorCode = 14 + // ErrNotAtomicTxsInPostPoolTxType type filter atomic transactions on POST /transactions-pool + ErrNotAtomicTxsInPostPoolTxType apiErrorType = "ErrNotAtomicTxsInPostPoolTx" + + // ErrFailedToGetCurrentBlockCode code when can't get current block in /slots request + ErrFailedToGetCurrentBlockCode apiErrorCode = 15 + // ErrFailedToGetCurrentBlockType type when can't get current block in /slots request + ErrFailedToGetCurrentBlockType apiErrorType = "ErrFailedToGetCurrentBlock" - // Internal error messages (used for logs or handling errors returned from internal comopnents) + // ErrFailedToGetAuctionVarsCode code when can't get auction vars in /slots request + ErrFailedToGetAuctionVarsCode apiErrorCode = 16 + // ErrFailedToGetAuctionVarsType type when can't get auction vars in /slots request + ErrFailedToGetAuctionVarsType apiErrorType = "ErrFailedToGetAuctionVars" + + // ErrFailedToAddEmptySlotCode code when can't add empty slot in /slots request + ErrFailedToAddEmptySlotCode apiErrorCode = 17 + // ErrFailedToAddEmptySlotType type when can't add empty slot in /slots request + ErrFailedToAddEmptySlotType apiErrorType = "ErrFailedToAddEmptySlot" + + // ErrTxsNotAtomic error message returned when receiving (and rejecting) txs in the atomic endpoint with not all txs being atomic + ErrTxsNotAtomic = "there is at least one transaction in the payload that could be forged without the others" + // ErrTxsNotAtomicCode error code + ErrTxsNotAtomicCode apiErrorCode = 18 + // ErrTxsNotAtomicType error type + ErrTxsNotAtomicType apiErrorType = "ErrTxsNotAtomic" + + // ErrSingleTxInAtomicEndpoint only one tx sent to the atomic-pool endpoint + ErrSingleTxInAtomicEndpoint = "to use the atomic-pool endpoint at least two transactions are required" + // ErrSingleTxInAtomicEndpointCode error code + ErrSingleTxInAtomicEndpointCode apiErrorCode = 19 + // ErrSingleTxInAtomicEndpointType error type + ErrSingleTxInAtomicEndpointType apiErrorType = "ErrSingleTxInAtomicEndpoint" + + // ErrInvalidRqOffset error message returned when received an invalid request offset + ErrInvalidRqOffset = "invalid requestOffset. Valid values goes from 0 to 7" + + // ErrRqOffsetOutOfBounds error message returned when transaction tries to access another out the bounds of the array + ErrRqOffsetOutOfBounds = "one of the transactions requested another one outside the bounds of the provided array" + // ErrRqOffsetOutOfBoundsCode error code + ErrRqOffsetOutOfBoundsCode = 20 + // ErrRqOffsetOutOfBoundsType error type + ErrRqOffsetOutOfBoundsType = "ErrRqOffsetOutOfBounds" + + // ErrInvalidAtomicGroupID error message returned when received an invalid AtomicGroupID + ErrInvalidAtomicGroupID = "invalid atomicGroupId" + // ErrInvalidAtomicGroupIDCode error code + ErrInvalidAtomicGroupIDCode = 21 + // ErrInvalidAtomicGroupIDType error type + ErrInvalidAtomicGroupIDType = "ErrInvalidAtomicGroupID" + + // ErrFailedToFindOffsetToRelativePositionCode error code when can't find offset to relative position + ErrFailedToFindOffsetToRelativePositionCode = 22 + // ErrFailedToFindOffsetToRelativePositionType error type + ErrFailedToFindOffsetToRelativePositionType = "ErrFailedToFindOffsetToRelativePosition" + + // ErrFeeTooLowCode code for fee too low error + ErrFeeTooLowCode apiErrorCode = 23 + // ErrFeeTooLowType type for fee too low error + ErrFeeTooLowType apiErrorType = "ErrFeeTooLow" + + // ErrFeeTooBigCode code for fee too big error + ErrFeeTooBigCode apiErrorCode = 24 + // ErrFeeTooBigType type for fee too big error + ErrFeeTooBigType apiErrorType = "ErrFeeTooBig" + + // 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" + + // Internal error messages (used for logs or handling errors returned from internal components) // errCtxTimeout error message received internally when context reaches timeout errCtxTimeout = "context deadline exceeded" +) - // ErrInvalidSymbol error message returned when receiving (and rejecting) an invalid Symbol - ErrInvalidSymbol = "Invalid Symbol" +type apiError struct { + Err error + Code apiErrorCode + Type apiErrorType +} - // ErrIsAtomic filter atomic transactions on POST /transactions-pool - ErrIsAtomic = "Thies endpoint does not accept atomic transactions" -) +type apiErrorResponse struct { + Message string `json:"message"` + Code apiErrorCode `json:"code"` + Type apiErrorType `json:"type"` +} + +func (a apiError) Error() string { + return a.Err.Error() +} diff --git a/api/exits.go b/api/exits.go index c2af42deb..535de5a9b 100644 --- a/api/exits.go +++ b/api/exits.go @@ -12,7 +12,11 @@ func (a *API) getExits(c *gin.Context) { // Get query parameters exitsFilters, err := parsers.ParseExitsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } @@ -38,7 +42,11 @@ func (a *API) getExit(c *gin.Context) { // Get batchNum and accountIndex batchNum, idx, err := parsers.ParseExitFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch tx from historyDB diff --git a/api/fiat.go b/api/fiat.go index 63f2e90df..1a0b6b1eb 100644 --- a/api/fiat.go +++ b/api/fiat.go @@ -1,7 +1,6 @@ package api import ( - "errors" "net/http" "github.com/gin-gonic/gin" @@ -13,7 +12,11 @@ func (a *API) getFiatCurrency(c *gin.Context) { // Get symbol symbol, err := parsers.ParseCurrencyFilter(c) if err != nil { - retBadReq(errors.New(ErrInvalidSymbol), c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch currency from historyDB @@ -34,7 +37,11 @@ func (a *API) getFiatCurrencies(c *gin.Context) { // Currency filters symbols, err := parsers.ParseCurrenciesFilters(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } diff --git a/api/handlers.go b/api/handlers.go index 061adadad..f3a8facf0 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -24,8 +24,10 @@ func retSQLErr(err error, c *gin.Context) { retDupKey := func(errCode pq.ErrorCode) { // https://www.postgresql.org/docs/current/errcodes-appendix.html if errCode == "23505" { - c.JSON(http.StatusConflict, errorMsg{ + c.JSON(http.StatusConflict, apiErrorResponse{ Message: ErrDuplicatedKey, + Code: ErrDuplicatedKeyCode, + Type: ErrDuplicatedKeyType, }) } else { c.JSON(http.StatusInternalServerError, errorMsg{ @@ -34,16 +36,20 @@ func retSQLErr(err error, c *gin.Context) { } } if errMsg == errCtxTimeout { - c.JSON(http.StatusServiceUnavailable, errorMsg{ + c.JSON(http.StatusServiceUnavailable, apiErrorResponse{ Message: ErrSQLTimeout, + Code: ErrSQLTimeoutCode, + Type: ErrSQLTimeoutType, }) } else if sqlErr, ok := tracerr.Unwrap(err).(*pq.Error); ok { retDupKey(sqlErr.Code) } else if sqlErr, ok := meddler.DriverErr(tracerr.Unwrap(err)); ok { retDupKey(sqlErr.(*pq.Error).Code) } else if tracerr.Unwrap(err) == sql.ErrNoRows { - c.JSON(http.StatusNotFound, errorMsg{ - Message: errMsg, + c.JSON(http.StatusNotFound, apiErrorResponse{ + Message: ErrSQLNoRows, + Code: ErrSQLNoRowsCode, + Type: ErrSQLNoRowsType, }) } else { c.JSON(http.StatusInternalServerError, errorMsg{ @@ -55,6 +61,16 @@ func retSQLErr(err error, c *gin.Context) { func retBadReq(err error, c *gin.Context) { log.Warnw("HTTP API Bad request error", "err", err) metric.CollectError(err) + if err, ok := err.(*apiError); ok { + unwrapError := tracerr.Unwrap(err.Err) + errMsg := unwrapError.Error() + c.JSON(http.StatusBadRequest, apiErrorResponse{ + Message: errMsg, + Code: err.Code, + Type: err.Type, + }) + return + } c.JSON(http.StatusBadRequest, errorMsg{ Message: err.Error(), }) diff --git a/api/health.go b/api/health.go index a7a80e59d..9e9815208 100644 --- a/api/health.go +++ b/api/health.go @@ -24,6 +24,10 @@ func (a *API) healthRoute(version string, ethClient *ethclient.Client, forgerAdd historyDBChecker := checkers.NewCheckerWithDB(a.h.DB().DB) healthHandler.AddChecker("historyDB", historyDBChecker) } + if a.stateDB != nil { + stateDBChecker := checkers.NewStateDBChecker(a.stateDB) + healthHandler.AddChecker("stateDB", stateDBChecker) + } healthHandler.AddInfo("version", version) t := time.Now().UTC() healthHandler.AddInfo("timestamp", t) diff --git a/api/parsers/account.go b/api/parsers/account.go index bd2695c85..a120e2ca4 100644 --- a/api/parsers/account.go +++ b/api/parsers/account.go @@ -17,10 +17,10 @@ type AccountFilter struct { } // ParseAccountFilter parses account filter to the account index -func ParseAccountFilter(c *gin.Context) (*common.Idx, error) { +func ParseAccountFilter(c *gin.Context) (common.QueryAccount, error) { var accountFilter AccountFilter if err := c.ShouldBindUri(&accountFilter); err != nil { - return nil, tracerr.Wrap(err) + return common.QueryAccount{}, tracerr.Wrap(err) } return common.StringToIdx(accountFilter.AccountIndex, "accountIndex") } diff --git a/api/parsers/atomicpool.go b/api/parsers/atomicpool.go new file mode 100644 index 000000000..88bc1437c --- /dev/null +++ b/api/parsers/atomicpool.go @@ -0,0 +1,29 @@ +package parsers + +import ( + "fmt" + + "github.com/gin-gonic/gin" + "github.com/hermeznetwork/hermez-node/common" + "github.com/hermeznetwork/tracerr" +) + +// AtomicGroupFilter struct for filtering atomic group request +type AtomicGroupFilter struct { + ID string `uri:"id" binding:"required"` +} + +// ParseParamAtomicGroupID func for parsing AtomicGroupID +func ParseParamAtomicGroupID(c *gin.Context) (common.AtomicGroupID, error) { + var atomicGroupFilter AtomicGroupFilter + if err := c.ShouldBindUri(&atomicGroupFilter); err != nil { + return common.AtomicGroupID{}, tracerr.Wrap(err) + } + + atomicGroupID, err := common.NewAtomicGroupIDFromString(atomicGroupFilter.ID) + if err != nil { + return common.AtomicGroupID{}, tracerr.Wrap(fmt.Errorf("invalid id")) + } + + return atomicGroupID, nil +} diff --git a/api/parsers/exits.go b/api/parsers/exits.go index 2f759b702..622f49c6e 100644 --- a/api/parsers/exits.go +++ b/api/parsers/exits.go @@ -21,12 +21,12 @@ func ParseExitFilter(c *gin.Context) (*uint, *common.Idx, error) { return nil, nil, tracerr.Wrap(err) } - idx, err := common.StringToIdx(exitFilter.AccountIndex, "accountIndex") + queryAccount, err := common.StringToIdx(exitFilter.AccountIndex, "accountIndex") if err != nil { return nil, nil, tracerr.Wrap(err) } - return &exitFilter.BatchNum, idx, nil + return &exitFilter.BatchNum, queryAccount.AccountIndex, nil } // ExitsFilters struct for holding exits filters @@ -85,7 +85,7 @@ func ParseExitsFilters(c *gin.Context, v *validator.Validate) (historydb.GetExit return historydb.GetExitsAPIRequest{}, tracerr.Wrap(err) } - idx, err := common.StringToIdx(exitsFilters.AccountIndex, "accountIndex") + queryAccount, err := common.StringToIdx(exitsFilters.AccountIndex, "accountIndex") if err != nil { return historydb.GetExitsAPIRequest{}, tracerr.Wrap(err) } @@ -94,7 +94,7 @@ func ParseExitsFilters(c *gin.Context, v *validator.Validate) (historydb.GetExit EthAddr: addr, Bjj: bjj, TokenID: tokenID, - Idx: idx, + Idx: queryAccount.AccountIndex, BatchNum: exitsFilters.BatchNum, OnlyPendingWithdraws: exitsFilters.OnlyPendingWithdraws, FromItem: exitsFilters.FromItem, diff --git a/api/parsers/slots.go b/api/parsers/slots.go index 2e9448aaf..fb02f6e7d 100644 --- a/api/parsers/slots.go +++ b/api/parsers/slots.go @@ -5,6 +5,7 @@ import ( "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db/historydb" "github.com/hermeznetwork/tracerr" + "gopkg.in/go-playground/validator.v9" ) // SlotFilter struct to get slot filter uri param from /slots/:slotNum request @@ -31,13 +32,37 @@ type SlotsFilters struct { Pagination } +// SlotsFiltersStructValidation func validating filters struct +func SlotsFiltersStructValidation(sl validator.StructLevel) { + ef := sl.Current().Interface().(SlotsFilters) + + if ef.MaxSlotNum == nil && ef.FinishedAuction == nil { + sl.ReportError(ef.MaxSlotNum, "maxSlotNum", "MaxSlotNum", "maxslotnumrequired", "") + sl.ReportError(ef.FinishedAuction, "finishedAuction", "FinishedAuction", "maxslotnumrequired", "") + } else if ef.FinishedAuction != nil { + if ef.MaxSlotNum == nil && !*ef.FinishedAuction { + sl.ReportError(ef.MaxSlotNum, "maxSlotNum", "MaxSlotNum", "maxslotnumrequired", "") + sl.ReportError(ef.FinishedAuction, "finishedAuction", "FinishedAuction", "maxslotnumrequired", "") + } + } else if ef.MaxSlotNum != nil && ef.MinSlotNum != nil { + if *ef.MinSlotNum > *ef.MaxSlotNum { + sl.ReportError(ef.MaxSlotNum, "maxSlotNum", "MaxSlotNum", "maxslotlessthanminslot", "") + sl.ReportError(ef.MinSlotNum, "minSlotNum", "MinSlotNum", "maxslotlessthanminslot", "") + } + } +} + // ParseSlotsFilters func for parsing slots filters to the GetBestBidsAPIRequest -func ParseSlotsFilters(c *gin.Context) (historydb.GetBestBidsAPIRequest, error) { +func ParseSlotsFilters(c *gin.Context, v *validator.Validate) (historydb.GetBestBidsAPIRequest, error) { var slotsFilters SlotsFilters if err := c.ShouldBindQuery(&slotsFilters); err != nil { return historydb.GetBestBidsAPIRequest{}, err } + if err := v.Struct(slotsFilters); err != nil { + return historydb.GetBestBidsAPIRequest{}, tracerr.Wrap(err) + } + wonByEthereumAddress, err := common.StringToEthAddr(slotsFilters.WonByEthereumAddress) if err != nil { return historydb.GetBestBidsAPIRequest{}, tracerr.Wrap(err) diff --git a/api/parsers/tokens.go b/api/parsers/tokens.go index 1c9fd9e2b..852697bcc 100644 --- a/api/parsers/tokens.go +++ b/api/parsers/tokens.go @@ -4,6 +4,7 @@ import ( "strconv" "strings" + ethCommon "github.com/ethereum/go-ethereum/common" "github.com/gin-gonic/gin" "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db/historydb" @@ -26,9 +27,10 @@ func ParseTokenFilter(c *gin.Context) (*uint, error) { // TokensFilters struct to get token query params from /tokens request type TokensFilters struct { - IDs string `form:"ids"` - Symbols string `form:"symbols"` - Name string `form:"name"` + IDs string `form:"ids"` + Symbols string `form:"symbols"` + Name string `form:"name"` + Addresses string `form:"addresses"` Pagination } @@ -41,7 +43,7 @@ func ParseTokensFilters(c *gin.Context) (historydb.GetTokensAPIRequest, error) { } var tokensIDs []common.TokenID if tokensFilters.IDs != "" { - ids := strings.Split(tokensFilters.IDs, ",") + ids := strings.Split(tokensFilters.IDs, "|") for _, id := range ids { idUint, err := strconv.Atoi(id) @@ -55,15 +57,25 @@ func ParseTokensFilters(c *gin.Context) (historydb.GetTokensAPIRequest, error) { var symbols []string if tokensFilters.Symbols != "" { - symbols = strings.Split(tokensFilters.Symbols, ",") + symbols = strings.Split(tokensFilters.Symbols, "|") + } + + var tokenAddresses []ethCommon.Address + if tokensFilters.Addresses != "" { + addrs := strings.Split(tokensFilters.Addresses, "|") + for _, addr := range addrs { + address := ethCommon.HexToAddress(addr) + tokenAddresses = append(tokenAddresses, address) + } } return historydb.GetTokensAPIRequest{ - Ids: tokensIDs, - Symbols: symbols, - Name: tokensFilters.Name, - FromItem: tokensFilters.FromItem, - Limit: tokensFilters.Limit, - Order: *tokensFilters.Order, + Ids: tokensIDs, + Symbols: symbols, + Name: tokensFilters.Name, + Addresses: tokenAddresses, + FromItem: tokensFilters.FromItem, + Limit: tokensFilters.Limit, + Order: *tokensFilters.Order, }, nil } diff --git a/api/parsers/txhistory.go b/api/parsers/txhistory.go index 4ea86ef96..40b90847f 100644 --- a/api/parsers/txhistory.go +++ b/api/parsers/txhistory.go @@ -19,11 +19,11 @@ type HistoryTxFilter struct { func ParseHistoryTxFilter(c *gin.Context) (common.TxID, error) { var historyTxFilter HistoryTxFilter if err := c.ShouldBindUri(&historyTxFilter); err != nil { - return common.TxID{}, err + return common.TxID{}, tracerr.Wrap(err) } txID, err := common.NewTxIDFromString(historyTxFilter.TxID) if err != nil { - return common.TxID{}, tracerr.Wrap(fmt.Errorf("invalid %s", err)) + return common.TxID{}, tracerr.Wrap(fmt.Errorf("invalid txID")) } return txID, nil } @@ -82,7 +82,7 @@ func HistoryTxsFiltersStructValidation(sl validator.StructLevel) { func ParseHistoryTxsFilters(c *gin.Context, v *validator.Validate) (historydb.GetTxsAPIRequest, error) { var historyTxsFilters HistoryTxsFilters if err := c.ShouldBindQuery(&historyTxsFilters); err != nil { - return historydb.GetTxsAPIRequest{}, err + return historydb.GetTxsAPIRequest{}, tracerr.Wrap(err) } if err := v.Struct(historyTxsFilters); err != nil { @@ -126,17 +126,17 @@ func ParseHistoryTxsFilters(c *gin.Context, v *validator.Validate) (historydb.Ge } // Idx - idx, err := common.StringToIdx(historyTxsFilters.AccountIndex, "accountIndex") + queryAccount, err := common.StringToIdx(historyTxsFilters.AccountIndex, "accountIndex") if err != nil { return historydb.GetTxsAPIRequest{}, tracerr.Wrap(err) } - fromIdx, err := common.StringToIdx(historyTxsFilters.FromAccountIndex, "fromAccountIndex") + fromQueryAccount, err := common.StringToIdx(historyTxsFilters.FromAccountIndex, "fromAccountIndex") if err != nil { return historydb.GetTxsAPIRequest{}, tracerr.Wrap(err) } - toIdx, err := common.StringToIdx(historyTxsFilters.ToAccountIndex, "toAccountIndex") + toQueryAccount, err := common.StringToIdx(historyTxsFilters.ToAccountIndex, "toAccountIndex") if err != nil { return historydb.GetTxsAPIRequest{}, tracerr.Wrap(err) } @@ -154,9 +154,9 @@ func ParseHistoryTxsFilters(c *gin.Context, v *validator.Validate) (historydb.Ge FromBjj: fromBjj, ToBjj: toBjj, TokenID: tokenID, - Idx: idx, - FromIdx: fromIdx, - ToIdx: toIdx, + Idx: queryAccount.AccountIndex, + FromIdx: fromQueryAccount.AccountIndex, + ToIdx: toQueryAccount.AccountIndex, BatchNum: historyTxsFilters.BatchNum, TxType: txType, IncludePendingL1s: historyTxsFilters.IncludePendingTxs, diff --git a/api/parsers/txpool.go b/api/parsers/txpool.go index 258205d25..a5c79a6c9 100644 --- a/api/parsers/txpool.go +++ b/api/parsers/txpool.go @@ -82,11 +82,11 @@ func PoolTxsTxsFiltersStructValidation(sl validator.StructLevel) { func ParsePoolTxsFilters(c *gin.Context, v *validator.Validate) (l2db.GetPoolTxsAPIRequest, error) { var poolTxsFilter PoolTxsFilters if err := c.BindQuery(&poolTxsFilter); err != nil { - return l2db.GetPoolTxsAPIRequest{}, err + return l2db.GetPoolTxsAPIRequest{}, tracerr.Wrap(err) } if err := v.Struct(poolTxsFilter); err != nil { - return l2db.GetPoolTxsAPIRequest{}, err + return l2db.GetPoolTxsAPIRequest{}, tracerr.Wrap(err) } // TokenID @@ -127,17 +127,17 @@ func ParsePoolTxsFilters(c *gin.Context, v *validator.Validate) (l2db.GetPoolTxs } // Idx - idx, err := common.StringToIdx(poolTxsFilter.AccountIndex, "accountIndex") + queryAccount, err := common.StringToIdx(poolTxsFilter.AccountIndex, "accountIndex") if err != nil { return l2db.GetPoolTxsAPIRequest{}, tracerr.Wrap(err) } - fromIdx, err := common.StringToIdx(poolTxsFilter.FromAccountIndex, "fromAccountIndex") + fromQueryAccount, err := common.StringToIdx(poolTxsFilter.FromAccountIndex, "fromAccountIndex") if err != nil { return l2db.GetPoolTxsAPIRequest{}, tracerr.Wrap(err) } - toIdx, err := common.StringToIdx(poolTxsFilter.ToAccountIndex, "toAccountIndex") + toQueryAccount, err := common.StringToIdx(poolTxsFilter.ToAccountIndex, "toAccountIndex") if err != nil { return l2db.GetPoolTxsAPIRequest{}, tracerr.Wrap(err) } @@ -161,9 +161,9 @@ func ParsePoolTxsFilters(c *gin.Context, v *validator.Validate) (l2db.GetPoolTxs ToBjj: toBjj, TxType: txType, TokenID: tokenID, - Idx: idx, - FromIdx: fromIdx, - ToIdx: toIdx, + Idx: queryAccount.AccountIndex, + FromIdx: fromQueryAccount.AccountIndex, + ToIdx: toQueryAccount.AccountIndex, State: txState, FromItem: poolTxsFilter.FromItem, diff --git a/api/slots.go b/api/slots.go index b03bcbac4..b0694455a 100644 --- a/api/slots.go +++ b/api/slots.go @@ -2,7 +2,6 @@ package api import ( "database/sql" - "errors" "net/http" "github.com/gin-gonic/gin" @@ -96,7 +95,11 @@ func (a *API) addEmptySlot(slots []SlotAPI, slotNum int64, currentBlockNum int64 func (a *API) getSlot(c *gin.Context) { slotNumUint, err := parsers.ParseSlotFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } currentBlock, err := a.h.GetLastBlockAPI() @@ -189,54 +192,41 @@ func (a *API) getSlots(c *gin.Context) { minSlotNumDflt := int64(0) // Get filters - filters, err := parsers.ParseSlotsFilters(c) + filters, err := parsers.ParseSlotsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } currentBlock, err := a.h.GetLastBlockAPI() if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrFailedToGetCurrentBlockCode, + Type: ErrFailedToGetCurrentBlockType, + }, c) return } auctionVars, err := a.h.GetAuctionVarsAPI() if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrFailedToGetAuctionVarsCode, + Type: ErrFailedToGetAuctionVarsType, + }, c) return } // Check filters - if filters.MaxSlotNum == nil && filters.FinishedAuction == nil { - retBadReq(errors.New("It is necessary to add maxSlotNum filter"), c) - return - } else if filters.FinishedAuction != nil { - if filters.MaxSlotNum == nil && !*filters.FinishedAuction { - retBadReq(errors.New("It is necessary to add maxSlotNum filter"), c) - return - } else if *filters.FinishedAuction { - currentBlock, err := a.h.GetLastBlockAPI() - if err != nil { - retBadReq(err, c) - return - } - currentSlot := a.getCurrentSlot(currentBlock.Num) - auctionVars, err := a.h.GetAuctionVarsAPI() - if err != nil { - retBadReq(err, c) - return - } - closedAuctionSlots := currentSlot + int64(auctionVars.ClosedAuctionSlots) - if filters.MaxSlotNum == nil { - filters.MaxSlotNum = &closedAuctionSlots - } else if closedAuctionSlots < *filters.MaxSlotNum { - filters.MaxSlotNum = &closedAuctionSlots - } - } - } else if filters.MaxSlotNum != nil && filters.MinSlotNum != nil { - if *filters.MinSlotNum > *filters.MaxSlotNum { - retBadReq(errors.New("It is necessary to add valid filter (minSlotNum <= maxSlotNum)"), c) - return + if filters.FinishedAuction != nil && *filters.FinishedAuction { + currentSlot := a.getCurrentSlot(currentBlock.Num) + closedAuctionSlots := currentSlot + int64(auctionVars.ClosedAuctionSlots) + if filters.MaxSlotNum == nil || closedAuctionSlots < *filters.MaxSlotNum { + filters.MaxSlotNum = &closedAuctionSlots } } if filters.MinSlotNum == nil { @@ -280,10 +270,6 @@ func (a *API) getSlots(c *gin.Context) { var slotsBids []SlotAPI if len(bids) > 0 { slotsBids = a.newSlotsAPIFromWinnerBids(filters.FromItem, filters.Order, bids, currentBlock.Num, auctionVars) - if err != nil { - retBadReq(err, c) - return - } } // Build the other slots @@ -309,7 +295,11 @@ func (a *API) getSlots(c *gin.Context) { if !found { slots, err = a.addEmptySlot(slots, i, currentBlock.Num, auctionVars, filters.FromItem, filters.Order) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrFailedToAddEmptySlotCode, + Type: ErrFailedToAddEmptySlotType, + }, c) return } } diff --git a/api/state.go b/api/state.go index 9e2535b4a..ddf032a4a 100644 --- a/api/state.go +++ b/api/state.go @@ -9,7 +9,7 @@ import ( func (a *API) getState(c *gin.Context) { stateAPI, err := a.h.GetStateAPI() if err != nil { - retBadReq(err, c) + retSQLErr(err, c) return } c.JSON(http.StatusOK, stateAPI) diff --git a/api/swagger.yml b/api/swagger.yml index 4374e16c7..093befc3f 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -36,6 +36,9 @@ info: * POST /account-creation-authorization: signed using an Ethereum key. * POST /transactions-pool: signed using BJJ key. + It's recommended to use the official SDKs for [Go](https://github.com/hermeznetwork/hermez-go-sdk), [JS](https://github.com/hermeznetwork/hermezjs) and [Flutter](https://github.com/hermeznetwork/hermez_flutter_sdk). + If for some reason the previous options doesn't suit your usecase, you can implement the signatures following the spec for [account creation authorizations](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=regular-rollup-account) and [L2 transactions](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=l2) + More details on how to sign will be provided soon. ### Contact @@ -46,12 +49,9 @@ info: * [Discord](https://bit.ly/3nohULM) * Email: hello@hermez.network * [Twitter](https://twitter.com/hermez_network) -# TODO: add further documentation on how to sign auths and txs version: "0.0.1" title: Hermez Network API -# TODO: update with support email -# termsOfService: 'http://swagger.io/terms/' license: name: license AGPLv3 url: 'https://www.gnu.org/licenses/agpl-3.0.html' @@ -387,6 +387,87 @@ paths: application/json: schema: $ref: '#/components/schemas/Error500' + '/atomic-pool': + post: + tags: + - Coordinator + summary: Add a collection of L2 transactions to the coordinator's pool. + description: >- + Send L2 transactions. The transactions will be stored in the transaction pool of the coordinator and eventually forged. + The main goal of sending transactions in groups is to use the atomic feature, where transactions are binded by the `request` fields, + and forced to be forged together. Transactions will be rejected unless all of them conform a single atomic group, in other words, they only + will be accepted if it's mandatory to forge all of them in a single batch. + operationId: postTx + requestBody: + description: Signed transactions. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostPoolL2Transactions' + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + $ref: '#/components/schemas/TransactionIds' + '400': + description: Bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/Error400' + '500': + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error500' + '/atomic-pool/{id}': + get: + tags: + - Coordinator + summary: Get details and status of transactions that conform an atomic group and are on the coordinators pool. + description: >- + Get transactions from the pool by its atomic group ID. This endpoint is specially useful for tracking the status of atomic transactions that may not be forged yet. + Only transactions from the pool will be returned. + Note that the transaction pool is different for each coordinator and therefore only a coordinator that has received a specific atomic group + will be able to provide information about that set of transactions. + operationId: getAtomicPool + parameters: + - name: id + in: path + description: Atomic group identifier. + required: true + schema: + $ref: '#/components/schemas/AtomicGroupID' + responses: + '200': + description: Successful operation. + content: + application/json: + schema: + $ref: '#/components/schemas/AtomicGroup' + '400': + description: Bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/Error400' + '404': + description: Not found. + content: + application/json: + schema: + $ref: '#/components/schemas/Error404' + '500': + description: Internal server error. + content: + application/json: + schema: + $ref: '#/components/schemas/Error500' + '/transactions-pool': post: tags: @@ -1183,22 +1264,30 @@ paths: description: Include only specific tokens by their Hermez identifiers. schema: type: string - description: Comma separated list of token identifiers - example: "2,44,689" + description: Pipeline "|" separated list of token identifiers + example: "2|44|689" - name: symbols in: query required: false description: Include only specific tokens by their symbols. schema: type: string - description: Comma separated list of token symbols. - example: "DAI,NEC,UMA" + description: Pipeline "|" separated list of token symbols. + example: "DAI|NEC|UMA" - name: name in: query required: false description: Include token(s) by their names (or a substring of the name). schema: type: string + - name: addresses + in: query + required: false + description: Include only specific tokens by their SC addresses. + schema: + type: string + description: Pipeline "|" separated list of token identifiers + example: "0xdac17f959d2ee523a2206207994597c13d831ec8|0xdac17f958e2ee523a2207206994597c12d831ec7|0xfac17f058d2ee527a2206206994597d13d831ec7" - name: fromItem in: query required: false @@ -1371,7 +1460,7 @@ components: nullable: true toHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network. If this is provided, toAccountIndex and toBjj must be null." + description: "Address of an Ethereum account linked to the Hermez Network. If this is provided, toAccountIndex and toBjj must be null." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" nullable: true @@ -1395,49 +1484,18 @@ components: signature: allOf: - $ref: '#/components/schemas/BJJSignature' - - description: Signature of the transaction. More info [here](https://idocs.hermez.io/#/spec/zkrollup/README?id=l2a-idl2). + - description: Signature of the transaction. More info [here](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=l2). - example: "72024a43f546b0e1d9d5d7c4c30c259102a9726363adcc4ec7b6aea686bcb5116f485c5542d27c4092ae0ceaf38e3bb44417639bd2070a58ba1aa1aab9d92c03" - requestFromAccountIndex: - type: string - description: References the `fromAccountIndex` of the requested transaction. - example: null - nullable: true - requestToAccountIndex: - type: string - description: References the `toAccountIndex` of the requested transaction. - example: null - nullable: true - requestToHezEthereumAddress: - type: string - description: References the `toHezEthereumAddress` of the requested transaction. - pattern: "^hez:0x[a-fA-F0-9]{40}$" - example: null - nullable: true - requestToBjj: - type: string - description: References the `toBjj` of the requested transaction. - pattern: "^hez:[A-Za-z0-9_-]{44}$" - example: null - nullable: true - requestTokenId: + maxNumBatch: type: integer - description: References the `tokenId` of the requested transaction. - example: null - nullable: true - requestAmount: - type: string - description: References the `amount` of the requested transaction. - example: null - nullable: true - requestFee: + description: Batch until the transaction can be forged. If the transaction isn't forged before batch `maxNumBatch`, it will never be forged. 0 means no restriction. + example: 0 + requestOffset: type: integer - description: References the `fee` of the requested transaction. - example: null - nullable: true - requestNonce: - type: integer - description: References the `nonce` of the requested transaction. - example: null + description: | + Identifier of the relative index of the transaction that would be linked. 0 means no linked transaction. + More info on how the identifiers are built [here](https://docs.hermez.io/#/developers/protocol/hermez-protocol/circuits/circuits?id=rq-tx-verifier) + example: 0 nullable: true example: id: '0x020000000001000000000006' @@ -1451,6 +1509,8 @@ components: fee: 0 nonce: 6 signature: 1a79dd5e661d58266901a0de8afb046b466c4c1af937100f627a421771f2911fa3fde8ea2e272b4802a8b1f1229689292acd6f7e8ab4cadc4ab37b6b9e13a101 + maxNumBatch: 0 + requestOffset: 0 additionalProperties: false required: - id @@ -1461,18 +1521,95 @@ components: - fee - nonce - signature + AtomicGroupID: + type: string + description: | + Identifier for atomic groups (set of transactions that have to be forged in the same batch, constrained by the request fields of the transactions on the group). + This identifier is calculated by hashing the concatenation of the transaction id bytes that conform the group). + example: '0x02b0c3d2fe18df3cd192d862804641190f99b79df3f1d6449b65fe246412120af0' + PostPoolL2Transactions: + type: object + properties: + atomicGroupId: + $ref: '#/components/schemas/AtomicGroupID' + transactions: + type: array + items: + $ref: '#/components/schemas/PostPoolL2Transaction' + required: + - atomicGroupId + - transactions + additionalProperties: false + example: + atomicGroupId: '0x0cd3d5c747145f70055156c565446441b60b8ca0dd7c8ddbb913529ed39773a7' + transactions: + - id: '0x02d4cbab2c32a7afb59c923cbf54a5f82d6ea1b1c553599a8a301c7109ea1eff17' + type: Transfer + tokenId: 0 + fromAccountIndex: hez:ETH:5000 + toAccountIndex: hez:ETH:5001 + toHezEthereumAddress: + toBjj: + amount: '10000000000' + fee: 200 + nonce: 0 + maxNumBatch: 0 + signature: dd4c93adedd4ee678819c89f45150fa098265d38a81042d72d5d8040ce64a500b40f2f7acb190620eb537bd22ec26310b660b76bba0697276173e2331e62b204 + requestOffset: 1 + - id: '0x0200d87a0e641fb84bb76a013cc3db1b423203f7dfc3f07afdbe3e7b78b6a527de' + type: Transfer + tokenId: 0 + fromAccountIndex: hez:ETH:5001 + toAccountIndex: hez:ETH:5002 + toHezEthereumAddress: + toBjj: + amount: '10000000000' + fee: 200 + nonce: 0 + maxNumBatch: 0 + signature: f20a2b83227e10b5e46b215c3b27f2bf1b39fb05ce3bb70bb1504ca9e700e49a99b023e15ddfbdc262be3996dbea255445c850f366f954ee352b665c0b648403 + requestOffset: 1 + - id: '0x0219ffcb5d99b25614ca81f94fd3947095b07aaf5bf4ba7d1078aa85d06c8a0fc2' + type: Transfer + tokenId: 0 + fromAccountIndex: hez:ETH:5002 + toAccountIndex: hez:ETH:5003 + toHezEthereumAddress: + toBjj: + amount: '10000000000' + fee: 200 + nonce: 0 + maxNumBatch: 0 + signature: d39134d192a63d0529d0575b5d7c0e1f3e9115c53186194b27e1c29c701442848206ee52e8b477a9804fb5cbff91f5e99ee04e4f1e22909bb6962df8464c0900 + requestOffset: 1 + - id: '0x02814c29cf2bbdaa024920fdd71c6d976a0bed2de6d91c61c38daee74bf6a08cba' + type: Transfer + tokenId: 0 + fromAccountIndex: hez:ETH:5003 + toAccountIndex: hez:ETH:5000 + toHezEthereumAddress: + toBjj: + amount: '10000000000' + fee: 200 + nonce: 0 + maxNumBatch: 0 + signature: 7b9e3e4e8148ccf22532148576118f1212ba2a9ed8ee50022d65bb5c2af5df0307894e739af9fdbc2ebb8a1accd2396144a4937c735bc38658fcf6a1caf4eb03 + requestOffset: 5 + PoolL2Transaction: type: object properties: id: $ref: '#/components/schemas/TransactionId' + itemId: + $ref: '#/components/schemas/ItemId' type: $ref: '#/components/schemas/TransactionTypeL2' fromAccountIndex: $ref: '#/components/schemas/AccountIndex' fromHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" nullable: true @@ -1491,7 +1628,7 @@ components: nullable: true toHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: null nullable: true @@ -1512,6 +1649,10 @@ components: $ref: '#/components/schemas/Nonce' state: $ref: '#/components/schemas/PoolL2TransactionState' + maxNumBatch: + type: integer + description: Batch until the transaction can be forged. If the transaction isn't forged before batch `maxNumBatch`, it will never be forged. 0 means no restriction. + example: 0 info: type: string description: "Info contains information about the status & State of the transaction. As for example, if the Tx has not been selected in the last batch due not enough Balance at the Sender account, this reason would appear at this parameter." @@ -1521,8 +1662,14 @@ components: signature: allOf: - $ref: '#/components/schemas/BJJSignature' - - description: Signature of the transaction. More info [here](https://idocs.hermez.io/#/spec/zkrollup/README?id=l2a-idl2). + - description: Signature of the transaction. More info [here](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=l2). - example: "72024a43f546b0e1d9d5d7c4c30c259102a9726363adcc4ec7b6aea686bcb5116f485c5542d27c4092ae0ceaf38e3bb44417639bd2070a58ba1aa1aab9d92c03" + errorType: + type: string + nullable: true + errorCode: + type: integer + nullable: true timestamp: type: string description: Moment in which the transaction was added to the pool. @@ -1543,7 +1690,7 @@ components: example: null requestToHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" nullable: true example: null @@ -1565,7 +1712,7 @@ components: example: null requestFee: type: integer - description: Index of the fee type to select, more info [here](https://idocs.hermez.io/#/spec/zkrollup/fee-table?id=transaction-fee-table). + description: Index of the fee type to select, more info [here](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=user). minimum: 0 maximum: 256 nullable: true @@ -1601,6 +1748,7 @@ components: toAccountIndex: hez:SCC:257 toBJJ: hez:r_trOasVEk0zNaalOoS9aLedu6mO7jI5XTIPu_zGXoyn toHezEthereumAddress: hez:0x00000000000000000000000000000000004Ab84F + maxNumBatch: 0 token: USD: 23.74 decimals: 7 @@ -1637,6 +1785,7 @@ components: - requestFee - requestNonce - token + additionalProperties: false PoolL2Transactions: type: object properties: @@ -1651,18 +1800,26 @@ components: - transactions - pendingItems additionalProperties: false + AtomicGroup: + type: array + items: + $ref: '#/components/schemas/PoolL2Transaction' TransactionId: type: string - description: Identifier for transactions. Used for any kind of transaction (both L1 and L2). More info on how the identifiers are built [here](https://idocs.hermez.io/#/spec/architecture/db/README?id=txid) + description: Identifier for transactions. Used for any kind of transaction (both L1 and L2). More info on how the identifiers are built [here](https://docs.hermez.io/#/developers/dev-guide?id=transaction-id) example: "0x00000000000001e240004700" + TransactionIds: + type: array + items: + $ref: '#/components/schemas/TransactionId' EthereumAddress: type: string - description: "Address of an Etherum account." + description: "Address of an Ethereum account." pattern: "^0x[a-fA-F0-9]{40}$" example: "0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" HezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" BJJ: @@ -1711,7 +1868,7 @@ components: pattern: "^\\d+$" FeeSelector: type: integer - description: Index of the fee type to select, more info [here](https://idocs.hermez.io/#/spec/zkrollup/fee-table?id=transaction-fee-table). + description: Index of the fee type to select, more info [here](https://docs.hermez.io/#/developers/protocol/hermez-protocol/protocol?id=user). minimum: 0 maximum: 256 example: 36 @@ -1826,7 +1983,7 @@ components: nullable: true fromHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" nullable: true @@ -1842,7 +1999,7 @@ components: - example: "hez:DAI:672" toHezEthereumAddress: type: string - description: "Address of an Etherum account linked to the Hermez Network." + description: "Address of an Ethereum account linked to the Hermez Network." pattern: "^hez:0x[a-fA-F0-9]{40}$" example: "hez:0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" nullable: true @@ -2751,7 +2908,7 @@ components: items: allOf: - $ref: '#/components/schemas/Slot' - - description: Last synchronized Etherum block. + - description: Last synchronized Ethereum block. pendingItems: $ref: '#/components/schemas/PendingItems' additionalProperties: false @@ -2850,12 +3007,12 @@ components: lastEthereumBlock: allOf: - $ref: '#/components/schemas/EthBlockNum' - - description: Current Etherum block. Note that this is the actual last block of Ethereum, not the last synchronized block by the node. + - description: Current Ethereum block. Note that this is the actual last block of Ethereum, not the last synchronized block by the node. - example: 3457437 lastSynchedBlock: allOf: - $ref: '#/components/schemas/EthBlockNum' - - description: Last synchronized Etherum block. Compare with lastEthereumBlock to check the synchronization status of the node. + - description: Last synchronized Ethereum block. Compare with lastEthereumBlock to check the synchronization status of the node. - example: 3457437 lastBatch: $ref: '#/components/schemas/Batch' @@ -3333,6 +3490,22 @@ components: - status - version additionalProperties: false + statedb: + type: object + description: state db connection status + properties: + status: + type: string + description: Status of the connection. Possible responses - UP or DOWN + example: UP + batchNum: + type: integer + description: current batch num in last checkpoint of the state db + example: 24025 + root: + type: integer + description: root of the underlying Merkle Tree in the last checkpoint of the state db + example: 20723800499378797360494097450413598946834655273323161758167114779532027183222 status: type: string description: Status of the hermez node. Possible responses - UP or DOWN @@ -3347,7 +3520,7 @@ components: example: v1.2.0 coordinatorForgerBalance: type: string - description: Coordinator balance in ether. Returned with 18 decimals. + description: Coordinator balance in ether. Returned with 18 decimals. Not returned if node not in coord mode example: 48901270356066543960 required: - historyDB @@ -3362,11 +3535,88 @@ components: properties: message: type: string + code: + type: integer + enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22] + description: > + Error codes: + * `1` - ErrParamValidationFailed error + * `2` - ErrDuplicatedKey error + * `3` - ErrSQLTimeout error + * `4` - ErrSQLNoRows error + * `5` - ErrExitAmount0 error + * `6` - ErrInvalidTxTypeOrTxID error + * `7` - ErrFeeOverflow error + * `8` - ErrGettingSenderAccount error + * `9` - ErrGettingSenderAccount error + * `10` - ErrInvalidNonce error + * `11` - ErrInvalidSignature error + * `12` - ErrGettingReceiverAccount error + * `13` - ErrCantSendToEthAddr error + * `14` - ErrNotAtomicTxsInPostPoolTx error + * `15` - ErrFailedToGetCurrentBlock error + * `16` - ErrFailedToGetAuctionVars error + * `17` - ErrFailedToAddEmptySlot error + * `18` - ErrTxsNotAtomic error + * `19` - ErrSingleTxInAtomicEndpoint error + * `20` - ErrRqOffsetOutOfBounds error + * `21` - ErrInvalidAtomicGroupID error + * `22` - ErrFailedToFindOffsetToRelativePositionCode error + type: + type: string + enum: + - ErrParamValidationFailed + - ErrDuplicatedKey + - ErrSQLTimeout + - ErrSQLNoRows + - ErrExitAmount0 + - ErrInvalidTxTypeOrTxID + - ErrFeeOverflow + - ErrGettingSenderAccount + - ErrAccountTokenNotEqualTxToken + - ErrInvalidNonce + - ErrInvalidSignature + - ErrGettingReceiverAccount + - ErrCantSendToEthAddr + - ErrNotAtomicTxsInPostPoolTx + - ErrFailedToGetCurrentBlock + - ErrFailedToGetAuctionVars + - ErrFailedToAddEmptySlot + - ErrTxsNotAtomic + - ErrSingleTxInAtomicEndpoint + - ErrInvalidAtomicGroupID + - ErrFailedToFindOffsetToRelativePosition + description: > + Error types: + * `ErrParamValidationFailed` - this error appears when user sends wrong info in query|uri|form params + * `ErrDuplicatedKey` - record already exists in db + * `ErrSQLTimeout` - node is under heavy pressure and sql connection timeout happened + * `ErrSQLNoRows` - there is no such item in database + * `ErrExitAmount0` - receiving (and rejecting) a tx of type exit with amount 0 in /transactions-pool request + * `ErrInvalidTxTypeOrTxID` - tx with invalid type or txID was sent in /transactions-pool request + * `ErrFeeOverflow` - tx with fee amount that doesn't fit in 128 bits was sent in /transactions-pool request + * `ErrGettingSenderAccount` - sender account for tx was not found in /transactions-pool request + * `ErrAccountTokenNotEqualTxToken` - account token is not equal to tx token in /transactions-pool request + * `ErrInvalidNonce` - invalid nonce was sent in /transactions-pool request + * `ErrInvalidSignature` - invalid signature was sent in /transactions-pool or /account-creation-authorization requests + * `ErrGettingReceiverAccount` - receiver account for tx was not fount in /transactions-pool request + * `ErrCantSendToEthAddr` - it's not possible to send to Eth address when there is no account index associated to this Eth address and token, or the coordinator hasn't got an authorization to create an account + * `ErrNotAtomicTxsInPostPoolTx` - user sending atomic tx to /transactions-pool request + * `ErrFailedToGetCurrentBlock` - can't get current block in /slots request + * `ErrFailedToGetAuctionVars` - can't get auction vars in /slots request + * `ErrFailedToAddEmptySlot` - can't add empty slot in /slots request + * `ErrTxsNotAtomic` - there is at least one transaction in the payload that could be forged without the others + * `ErrSingleTxInAtomicEndpoint` - to use the atomic-pool endpoint at least two transactions are required + * `ErrRqOffsetOutOfBounds` - one of the transactions requested another one outside the bounds of the provided array + * `ErrInvalidAtomicGroupID` - invalid atomicGroupId + * `ErrFailedToFindOffsetToRelativePosition` - can't find offset to relative position Error400: allOf: - $ref: '#/components/schemas/Error' - example: message: Invalid signature. + code: 4 + type: ErrInvalidSignature Error404: allOf: - $ref: '#/components/schemas/Error' diff --git a/api/token.go b/api/token.go index 53108a107..95b486076 100644 --- a/api/token.go +++ b/api/token.go @@ -13,7 +13,11 @@ func (a *API) getToken(c *gin.Context) { // Get TokenID tokenIDUint, err := parsers.ParseTokenFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } tokenID := common.TokenID(*tokenIDUint) @@ -30,7 +34,11 @@ func (a *API) getTokens(c *gin.Context) { // Account filters filters, err := parsers.ParseTokensFilters(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch exits from historyDB diff --git a/api/token_test.go b/api/token_test.go index 0167fca02..7bd2027cc 100644 --- a/api/token_test.go +++ b/api/token_test.go @@ -63,7 +63,7 @@ func TestGetTokens(t *testing.T) { // Get by tokenIds fetchedTokens = []historydb.TokenWithUSD{} limit = 7 - stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID)) + stringIds := strconv.Itoa(int(tc.tokens[2].TokenID)) + "|" + strconv.Itoa(int(tc.tokens[5].TokenID)) + "|" + strconv.Itoa(int(tc.tokens[6].TokenID)) path = fmt.Sprintf( "%s?ids=%s&limit=%d", endpoint, stringIds, limit, @@ -79,7 +79,7 @@ func TestGetTokens(t *testing.T) { // Get by symbols fetchedTokens = []historydb.TokenWithUSD{} limit = 7 - stringSymbols := tc.tokens[1].Symbol + "," + tc.tokens[3].Symbol + stringSymbols := tc.tokens[1].Symbol + "|" + tc.tokens[3].Symbol path = fmt.Sprintf( "%s?symbols=%s&limit=%d", endpoint, stringSymbols, limit, @@ -106,14 +106,30 @@ func TestGetTokens(t *testing.T) { tokensFiltered = append(tokensFiltered, tc.tokens[8]) assertTokensAPIs(t, tokensFiltered, fetchedTokens) + // Get by addresses + fetchedTokens = []historydb.TokenWithUSD{} + limit = 7 + stringAddresses := tc.tokens[1].EthAddr.String() + "|" + tc.tokens[3].EthAddr.String() + path = fmt.Sprintf( + "%s?addresses=%s&limit=%d", + endpoint, stringAddresses, limit, + ) + err = doGoodReqPaginated(path, db.OrderAsc, &testTokensResponse{}, appendIter) + assert.NoError(t, err) + tokensFiltered = nil + tokensFiltered = append(tokensFiltered, tc.tokens[1]) + tokensFiltered = append(tokensFiltered, tc.tokens[3]) + assertTokensAPIs(t, tokensFiltered, fetchedTokens) + // Multiple filters fetchedTokens = []historydb.TokenWithUSD{} limit = 5 - stringSymbols = tc.tokens[2].Symbol + "," + tc.tokens[6].Symbol - stringIds = strconv.Itoa(int(tc.tokens[2].TokenID)) + "," + strconv.Itoa(int(tc.tokens[5].TokenID)) + "," + strconv.Itoa(int(tc.tokens[6].TokenID)) + stringSymbols = tc.tokens[2].Symbol + "|" + tc.tokens[6].Symbol + stringIds = strconv.Itoa(int(tc.tokens[2].TokenID)) + "|" + strconv.Itoa(int(tc.tokens[5].TokenID)) + "|" + strconv.Itoa(int(tc.tokens[6].TokenID)) + stringAddresses = tc.tokens[2].EthAddr.String() + "|" + tc.tokens[6].EthAddr.String() + "|" + tc.tokens[4].EthAddr.String() path = fmt.Sprintf( - "%s?symbols=%s&ids=%s&limit=%d", - endpoint, stringSymbols, stringIds, limit, + "%s?symbols=%s&ids=%s&addresses=%s&limit=%d", + endpoint, stringSymbols, stringIds, stringAddresses, limit, ) err = doGoodReqPaginated(path, db.OrderAsc, &testTokensResponse{}, appendIter) assert.NoError(t, err) diff --git a/api/txshistory.go b/api/txshistory.go index 3fc2855d8..d5ef1db72 100644 --- a/api/txshistory.go +++ b/api/txshistory.go @@ -11,7 +11,11 @@ import ( func (a *API) getHistoryTxs(c *gin.Context) { txFilters, err := parsers.ParseHistoryTxsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch txs from historyDB @@ -36,7 +40,11 @@ func (a *API) getHistoryTx(c *gin.Context) { // Get TxID txID, err := parsers.ParseHistoryTxFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch tx from historyDB diff --git a/api/txshistory_test.go b/api/txshistory_test.go index 6d778b03d..d23109d8f 100644 --- a/api/txshistory_test.go +++ b/api/txshistory_test.go @@ -347,7 +347,7 @@ func TestGetHistoryTxs(t *testing.T) { fetchedTxs = []testTx{} limit = 4 idxStr := tc.txs[0].ToIdx - idx, err := common.StringToIdx(idxStr, "") + queryAccount, err := common.StringToIdx(idxStr, "") assert.NoError(t, err) path = fmt.Sprintf( "%s?accountIndex=%s&limit=%d", @@ -360,18 +360,18 @@ func TestGetHistoryTxs(t *testing.T) { if tc.txs[i].BatchNum == nil { continue } - var fromIdx *common.Idx + var fromQueryAccount common.QueryAccount if tc.txs[i].FromIdx != nil { - fromIdx, err = common.StringToIdx(*tc.txs[i].FromIdx, "") + fromQueryAccount, err = common.StringToIdx(*tc.txs[i].FromIdx, "") assert.NoError(t, err) - if *fromIdx == *idx { + if *fromQueryAccount.AccountIndex == *queryAccount.AccountIndex { idxTxs = append(idxTxs, tc.txs[i]) continue } } - toIdx, err := common.StringToIdx((tc.txs[i].ToIdx), "") + toQueryAccount, err := common.StringToIdx((tc.txs[i].ToIdx), "") assert.NoError(t, err) - if *toIdx == *idx { + if *toQueryAccount.AccountIndex == *queryAccount.AccountIndex { idxTxs = append(idxTxs, tc.txs[i]) } } @@ -383,11 +383,11 @@ func TestGetHistoryTxs(t *testing.T) { err = doGoodReqPaginated(path, db.OrderAsc, &testTxsResponse{}, appendIter) assert.NoError(t, err) for i := 0; i < len(tc.txs); i++ { - var fromIdx *common.Idx + var fromQueryAccount common.QueryAccount if tc.txs[i].FromIdx != nil { - fromIdx, err = common.StringToIdx(*tc.txs[i].FromIdx, "") + fromQueryAccount, err = common.StringToIdx(*tc.txs[i].FromIdx, "") assert.NoError(t, err) - if *fromIdx == *idx { + if *fromQueryAccount.AccountIndex == *queryAccount.AccountIndex { idxTxs = append(idxTxs, tc.txs[i]) continue } @@ -401,9 +401,9 @@ func TestGetHistoryTxs(t *testing.T) { assert.NoError(t, err) idxTxs = []testTx{} for i := 0; i < len(tc.txs); i++ { - toIdx, err := common.StringToIdx(tc.txs[i].ToIdx, "") + toQueryAccount, err := common.StringToIdx(tc.txs[i].ToIdx, "") assert.NoError(t, err) - if *toIdx == *idx { + if *toQueryAccount.AccountIndex == *queryAccount.AccountIndex { idxTxs = append(idxTxs, tc.txs[i]) } } @@ -495,7 +495,7 @@ func TestGetHistoryTxs(t *testing.T) { // 400 path = fmt.Sprintf( "%s?accountIndex=%s&hezEthereumAddress=%s", - endpoint, idx, account.EthAddr, + endpoint, queryAccount.AccountIndex, account.EthAddr, ) err = doBadReq("GET", path, nil, 400) assert.NoError(t, err) diff --git a/api/txspool.go b/api/txspool.go index 5874e6394..4aa511cbe 100644 --- a/api/txspool.go +++ b/api/txspool.go @@ -5,50 +5,78 @@ import ( "fmt" "math/big" "net/http" + "strings" - 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/db/l2db" "github.com/hermeznetwork/tracerr" - "github.com/iden3/go-iden3-crypto/babyjub" ) func (a *API) postPoolTx(c *gin.Context) { // Parse body - var receivedTx receivedPoolTx + var receivedTx common.PoolL2Tx if err := c.ShouldBindJSON(&receivedTx); err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } - // Transform from received to insert format and validate - writeTx := receivedTx.toPoolL2TxWrite() - // Reject atomic transactions - if isAtomic(*writeTx) { - retBadReq(errors.New(ErrIsAtomic), c) + if isAtomic(receivedTx) { + retBadReq(&apiError{ + Err: errors.New(ErrNotAtomicTxsInPostPoolTx), + Code: ErrNotAtomicTxsInPostPoolTxCode, + Type: ErrNotAtomicTxsInPostPoolTxType, + }, c) return } - if err := a.verifyPoolL2TxWrite(writeTx); err != nil { - retBadReq(err, c) + // Check that tx is valid + if err := a.verifyPoolL2Tx(receivedTx); err != nil { + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } - writeTx.ClientIP = c.ClientIP() + receivedTx.ClientIP = c.ClientIP() + receivedTx.Info = "" // Insert to DB - if err := a.l2.AddTxAPI(writeTx); err != nil { + if err := a.l2.AddTxAPI(&receivedTx); err != nil { + if strings.Contains(err.Error(), "< minFeeUSD") { + retBadReq(&apiError{ + Err: err, + Code: ErrFeeTooLowCode, + Type: ErrFeeTooLowType, + }, c) + return + } else if strings.Contains(err.Error(), "> maxFeeUSD") { + retBadReq(&apiError{ + Err: err, + Code: ErrFeeTooBigCode, + Type: ErrFeeTooBigType, + }, c) + return + } retSQLErr(err, c) return } // Return TxID - c.JSON(http.StatusOK, writeTx.TxID.String()) + c.JSON(http.StatusOK, receivedTx.TxID.String()) } func (a *API) getPoolTx(c *gin.Context) { // Get TxID txID, err := parsers.ParsePoolTxFilter(c) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch tx from l2DB @@ -64,7 +92,11 @@ func (a *API) getPoolTx(c *gin.Context) { func (a *API) getPoolTxs(c *gin.Context) { txAPIRequest, err := parsers.ParsePoolTxsFilters(c, a.validate) if err != nil { - retBadReq(err, c) + retBadReq(&apiError{ + Err: err, + Code: ErrParamValidationFailedCode, + Type: ErrParamValidationFailedType, + }, c) return } // Fetch txs from l2DB @@ -85,192 +117,104 @@ func (a *API) getPoolTxs(c *gin.Context) { }) } -type receivedPoolTx struct { - TxID common.TxID `json:"id" binding:"required"` - Type common.TxType `json:"type" binding:"required"` - TokenID common.TokenID `json:"tokenId"` - FromIdx apitypes.StrHezIdx `json:"fromAccountIndex" binding:"required"` - ToIdx *apitypes.StrHezIdx `json:"toAccountIndex"` - ToEthAddr *apitypes.StrHezEthAddr `json:"toHezEthereumAddress"` - ToBJJ *apitypes.StrHezBJJ `json:"toBjj"` - Amount apitypes.StrBigInt `json:"amount" binding:"required"` - Fee common.FeeSelector `json:"fee"` - Nonce common.Nonce `json:"nonce"` - Signature babyjub.SignatureComp `json:"signature" binding:"required"` - RqFromIdx *apitypes.StrHezIdx `json:"requestFromAccountIndex"` - RqToIdx *apitypes.StrHezIdx `json:"requestToAccountIndex"` - RqToEthAddr *apitypes.StrHezEthAddr `json:"requestToHezEthereumAddress"` - RqToBJJ *apitypes.StrHezBJJ `json:"requestToBjj"` - RqTokenID *common.TokenID `json:"requestTokenId"` - RqAmount *apitypes.StrBigInt `json:"requestAmount"` - RqFee *common.FeeSelector `json:"requestFee"` - RqNonce *common.Nonce `json:"requestNonce"` -} - -func (tx *receivedPoolTx) toPoolL2TxWrite() *l2db.PoolL2TxWrite { - f := new(big.Float).SetInt((*big.Int)(&tx.Amount)) - amountF, _ := f.Float64() - return &l2db.PoolL2TxWrite{ - TxID: tx.TxID, - FromIdx: common.Idx(tx.FromIdx), - ToIdx: (*common.Idx)(tx.ToIdx), - ToEthAddr: (*ethCommon.Address)(tx.ToEthAddr), - ToBJJ: (*babyjub.PublicKeyComp)(tx.ToBJJ), - TokenID: tx.TokenID, - Amount: (*big.Int)(&tx.Amount), - AmountFloat: amountF, - Fee: tx.Fee, - Nonce: tx.Nonce, - State: common.PoolL2TxStatePending, - Signature: tx.Signature, - RqFromIdx: (*common.Idx)(tx.RqFromIdx), - RqToIdx: (*common.Idx)(tx.RqToIdx), - RqToEthAddr: (*ethCommon.Address)(tx.RqToEthAddr), - RqToBJJ: (*babyjub.PublicKeyComp)(tx.RqToBJJ), - RqTokenID: tx.RqTokenID, - RqAmount: (*big.Int)(tx.RqAmount), - RqFee: tx.RqFee, - RqNonce: tx.RqNonce, - Type: tx.Type, - } -} - -func (a *API) verifyPoolL2TxWrite(txw *l2db.PoolL2TxWrite) error { - poolTx := common.PoolL2Tx{ - TxID: txw.TxID, - FromIdx: txw.FromIdx, - TokenID: txw.TokenID, - Amount: txw.Amount, - Fee: txw.Fee, - Nonce: txw.Nonce, - // State: txw.State, - Signature: txw.Signature, - RqAmount: txw.RqAmount, - Type: txw.Type, - } - // ToIdx - if txw.ToIdx != nil { - poolTx.ToIdx = *txw.ToIdx - } - // ToEthAddr - if txw.ToEthAddr == nil { - poolTx.ToEthAddr = common.EmptyAddr - } else { - poolTx.ToEthAddr = *txw.ToEthAddr - } - // ToBJJ - if txw.ToBJJ == nil { - poolTx.ToBJJ = common.EmptyBJJComp - } else { - poolTx.ToBJJ = *txw.ToBJJ - } - // RqFromIdx - if txw.RqFromIdx != nil { - poolTx.RqFromIdx = *txw.RqFromIdx - } - // RqToIdx - if txw.RqToIdx != nil { - poolTx.RqToIdx = *txw.RqToIdx - } - // RqToEthAddr - if txw.RqToEthAddr == nil { - poolTx.RqToEthAddr = common.EmptyAddr - } else { - poolTx.RqToEthAddr = *txw.RqToEthAddr - } - // RqToBJJ - if txw.RqToBJJ == nil { - poolTx.RqToBJJ = common.EmptyBJJComp - } else { - poolTx.RqToBJJ = *txw.RqToBJJ - } - // RqTokenID - if txw.RqTokenID != nil { - poolTx.RqTokenID = *txw.RqTokenID - } - // RqFee - if txw.RqFee != nil { - poolTx.RqFee = *txw.RqFee - } - // RqNonce - if txw.RqNonce != nil { - poolTx.RqNonce = *txw.RqNonce - } +func (a *API) verifyPoolL2Tx(tx common.PoolL2Tx) error { // Check type and id - _, err := common.NewPoolL2Tx(&poolTx) + _, err := common.NewPoolL2Tx(&tx) if err != nil { - return tracerr.Wrap(err) + return &apiError{ + Err: tracerr.Wrap(err), + Code: ErrInvalidTxTypeOrTxIDCode, + Type: ErrInvalidTxTypeOrTxIDType, + } } // Validate feeAmount - _, err = common.CalcFeeAmount(poolTx.Amount, poolTx.Fee) + _, err = common.CalcFeeAmount(tx.Amount, tx.Fee) if err != nil { - return tracerr.Wrap(err) + return &apiError{ + Err: tracerr.Wrap(err), + Code: ErrFeeOverflowCode, + Type: ErrFeeOverflowType, + } } // Get sender account information - account, err := a.h.GetCommonAccountAPI(poolTx.FromIdx) + account, err := a.h.GetCommonAccountAPI(tx.FromIdx) if err != nil { - return tracerr.Wrap(fmt.Errorf("Error getting from account: %w", err)) + return &apiError{ + Err: tracerr.Wrap(fmt.Errorf("error getting sender account, idx %s, error: %w", tx.FromIdx, err)), + Code: ErrGettingSenderAccountCode, + Type: ErrGettingSenderAccountType, + } } // Validate sender: // TokenID - if poolTx.TokenID != account.TokenID { - return tracerr.Wrap(fmt.Errorf("tx.TokenID (%v) != account.TokenID (%v)", - poolTx.TokenID, account.TokenID)) + if tx.TokenID != account.TokenID { + return &apiError{ + Err: tracerr.Wrap(fmt.Errorf("tx.TokenID (%v) != account.TokenID (%v)", + tx.TokenID, account.TokenID)), + Code: ErrAccountTokenNotEqualTxTokenCode, + Type: ErrAccountTokenNotEqualTxTokenType, + } } // Nonce - if poolTx.Nonce < account.Nonce { - return tracerr.Wrap(fmt.Errorf("poolTx.Nonce (%v) < account.Nonce (%v)", - poolTx.Nonce, account.Nonce)) + if tx.Nonce < account.Nonce { + return &apiError{ + Err: tracerr.Wrap(fmt.Errorf("tx.Nonce (%v) < account.Nonce (%v)", + tx.Nonce, account.Nonce)), + Code: ErrInvalidNonceCode, + Type: ErrInvalidNonceType, + } } // Check signature - if !poolTx.VerifySignature(a.cg.ChainID, account.BJJ) { - return tracerr.Wrap(errors.New("wrong signature")) + if !tx.VerifySignature(a.cg.ChainID, account.BJJ) { + return &apiError{ + Err: tracerr.Wrap(errors.New("wrong signature")), + Code: ErrInvalidSignatureCode, + Type: ErrInvalidSignatureType, + } } - // Check destinatary, note that transactions that are not transfers - // will always be valid in terms of destinatary (they use special ToIdx by protocol) - switch poolTx.Type { + switch tx.Type { + // Check destination, note that transactions that are not transfers + // will always be valid in terms of destination (they use special ToIdx by protocol) case common.TxTypeTransfer: // ToIdx exists and match token - toAccount, err := a.h.GetCommonAccountAPI(poolTx.ToIdx) - if err != nil { - return tracerr.Wrap(fmt.Errorf("Error getting to account: %w", err)) - } - if poolTx.TokenID != toAccount.TokenID { - return tracerr.Wrap(fmt.Errorf("tx.TokenID (%v) != toAccount.TokenID (%v)", - poolTx.TokenID, toAccount.TokenID)) - } - case common.TxTypeTransferToEthAddr: - // ToEthAddr has account created with matching token ID or authorization - ok, err := a.h.CanSendToEthAddr(poolTx.ToEthAddr, poolTx.TokenID) + toAccount, err := a.h.GetCommonAccountAPI(tx.ToIdx) if err != nil { - return err + return &apiError{ + Err: tracerr.Wrap(fmt.Errorf("error getting receiver account, idx %s, err: %w", tx.ToIdx, err)), + Code: ErrGettingReceiverAccountCode, + Type: ErrGettingReceiverAccountType, + } } - if !ok { - return tracerr.Wrap(fmt.Errorf( - "Destination eth addr (%v) has not a valid account created nor authorization", - poolTx.ToEthAddr, - )) + if tx.TokenID != toAccount.TokenID { + return &apiError{ + Err: tracerr.Wrap(fmt.Errorf("tx.TokenID (%v) != toAccount.TokenID (%v)", + tx.TokenID, toAccount.TokenID)), + Code: ErrAccountTokenNotEqualTxTokenCode, + Type: ErrAccountTokenNotEqualTxTokenType, + } } - } // Extra sanity checks: those checks are valid as per the protocol, but are very likely to // have unexpected side effects that could have a negative impact on users - switch poolTx.Type { case common.TxTypeExit: - if poolTx.Amount.Cmp(big.NewInt(0)) <= 0 { - return tracerr.New(ErrExitAmount0) + if tx.Amount.Cmp(big.NewInt(0)) <= 0 { + return &apiError{ + Err: tracerr.New(ErrExitAmount0), + Code: ErrExitAmount0Code, + Type: ErrExitAmount0Type, + } } } return nil } -func isAtomic(tx l2db.PoolL2TxWrite) bool { +func isAtomic(tx common.PoolL2Tx) bool { // If a single "Rq" field is different from 0 - return (tx.RqFromIdx != nil && *tx.RqFromIdx != 0) || - (tx.RqToIdx != nil && *tx.RqToIdx != 0) || - (tx.RqToEthAddr != nil && *tx.RqToEthAddr != common.EmptyAddr) || - (tx.RqToBJJ != nil && *tx.RqToBJJ != common.EmptyBJJComp) || - (tx.RqAmount != nil && tx.RqAmount != big.NewInt(0)) || - (tx.RqFee != nil && *tx.RqFee != 0) || - (tx.RqNonce != nil && *tx.RqNonce != 0) || - (tx.RqTokenID != nil && *tx.RqTokenID != 0) + return tx.RqFromIdx != 0 || + tx.RqToIdx != 0 || + tx.RqToEthAddr != common.EmptyAddr || + tx.RqToBJJ != common.EmptyBJJComp || + (tx.RqAmount != nil && tx.RqAmount.Cmp(big.NewInt(0)) != 0) || + tx.RqFee != 0 || + tx.RqNonce != 0 || + tx.RqTokenID != 0 } diff --git a/api/txspool_test.go b/api/txspool_test.go index e757a96b1..f7980f2e3 100644 --- a/api/txspool_test.go +++ b/api/txspool_test.go @@ -2,8 +2,6 @@ package api import ( "bytes" - "crypto/ecdsa" - "encoding/binary" "encoding/hex" "encoding/json" "fmt" @@ -11,7 +9,6 @@ import ( "testing" "time" - ethCrypto "github.com/ethereum/go-ethereum/crypto" "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db" "github.com/hermeznetwork/hermez-node/db/historydb" @@ -71,124 +68,82 @@ func (t testPoolTxsResponse) Len() int { func (t testPoolTxsResponse) New() Pendinger { return &testPoolTxsResponse{} } -// testPoolTxSend is a struct to be used as a JSON body -// when testing POST /transactions-pool -type testPoolTxSend struct { - TxID common.TxID `json:"id" binding:"required"` - Type common.TxType `json:"type" binding:"required"` - TokenID common.TokenID `json:"tokenId"` - FromIdx string `json:"fromAccountIndex" binding:"required"` - ToIdx *string `json:"toAccountIndex"` - ToEthAddr *string `json:"toHezEthereumAddress"` - ToBJJ *string `json:"toBjj"` - Amount string `json:"amount" binding:"required"` - Fee common.FeeSelector `json:"fee"` - Nonce common.Nonce `json:"nonce"` - Signature babyjub.SignatureComp `json:"signature" binding:"required"` - RqFromIdx *string `json:"requestFromAccountIndex"` - RqToIdx *string `json:"requestToAccountIndex"` - RqToEthAddr *string `json:"requestToHezEthereumAddress"` - RqToBJJ *string `json:"requestToBjj"` - RqTokenID *common.TokenID `json:"requestTokenId"` - RqAmount *string `json:"requestAmount"` - RqFee *common.FeeSelector `json:"requestFee"` - RqNonce *common.Nonce `json:"requestNonce"` -} - func genTestPoolTxs( poolTxs []common.PoolL2Tx, tokens []historydb.TokenWithUSD, accs []common.Account, -) (poolTxsToSend []testPoolTxSend, poolTxsToReceive []testPoolTxReceive) { - poolTxsToSend = []testPoolTxSend{} +) (poolTxsToSend []common.PoolL2Tx, poolTxsToReceive []testPoolTxReceive) { + poolTxsToSend = []common.PoolL2Tx{} poolTxsToReceive = []testPoolTxReceive{} - for _, poolTx := range poolTxs { - // common.PoolL2Tx ==> testPoolTxSend - token := getTokenByID(poolTx.TokenID, tokens) - genSendTx := testPoolTxSend{ - TxID: poolTx.TxID, - Type: poolTx.Type, - TokenID: poolTx.TokenID, - FromIdx: common.IdxToHez(poolTx.FromIdx, token.Symbol), - Amount: poolTx.Amount.String(), - Fee: poolTx.Fee, - Nonce: poolTx.Nonce, - Signature: poolTx.Signature, - RqFee: &poolTx.RqFee, - RqNonce: &poolTx.RqNonce, + for i := range poolTxs { + // common.PoolL2Tx ==> poolTxsToSend (add token symbols for proper marshaling) + token := getTokenByID(poolTxs[i].TokenID, tokens) + txToSend := poolTxs[i] + txToSend.TokenSymbol = token.Symbol + var rqToken historydb.TokenWithUSD + if poolTxs[i].RqToIdx != 0 { + rqToken = getTokenByID(poolTxs[i].RqTokenID, tokens) } + poolTxsToSend = append(poolTxsToSend, txToSend) // common.PoolL2Tx ==> testPoolTxReceive genReceiveTx := testPoolTxReceive{ - TxID: poolTx.TxID, - Type: poolTx.Type, - FromIdx: common.IdxToHez(poolTx.FromIdx, token.Symbol), - Amount: poolTx.Amount.String(), - Fee: poolTx.Fee, - Nonce: poolTx.Nonce, - State: poolTx.State, - Signature: poolTx.Signature, - Timestamp: poolTx.Timestamp, - // BatchNum: poolTx.BatchNum, - RqFee: &poolTx.RqFee, - RqNonce: &poolTx.RqNonce, - Token: token, + TxID: poolTxs[i].TxID, + Type: poolTxs[i].Type, + FromIdx: common.IdxToHez(poolTxs[i].FromIdx, token.Symbol), + Amount: poolTxs[i].Amount.String(), + Fee: poolTxs[i].Fee, + Nonce: poolTxs[i].Nonce, + State: poolTxs[i].State, + Signature: poolTxs[i].Signature, + Timestamp: poolTxs[i].Timestamp, + Token: token, } - fromAcc := getAccountByIdx(poolTx.FromIdx, accs) + fromAcc := getAccountByIdx(poolTxs[i].FromIdx, accs) fromAddr := common.EthAddrToHez(fromAcc.EthAddr) genReceiveTx.FromEthAddr = &fromAddr fromBjj := common.BjjToString(fromAcc.BJJ) genReceiveTx.FromBJJ = &fromBjj - if poolTx.ToIdx != 0 { - toIdx := common.IdxToHez(poolTx.ToIdx, token.Symbol) - genSendTx.ToIdx = &toIdx - genReceiveTx.ToIdx = &toIdx - } - if poolTx.ToEthAddr != common.EmptyAddr { - toEth := common.EthAddrToHez(poolTx.ToEthAddr) - genSendTx.ToEthAddr = &toEth + toIdx := common.IdxToHez(poolTxs[i].ToIdx, token.Symbol) + genReceiveTx.ToIdx = &toIdx + if poolTxs[i].ToEthAddr != common.EmptyAddr { + toEth := common.EthAddrToHez(poolTxs[i].ToEthAddr) genReceiveTx.ToEthAddr = &toEth - } else if poolTx.ToIdx > 255 { - acc := getAccountByIdx(poolTx.ToIdx, accs) + } else if poolTxs[i].ToIdx > 255 { + acc := getAccountByIdx(poolTxs[i].ToIdx, accs) addr := common.EthAddrToHez(acc.EthAddr) genReceiveTx.ToEthAddr = &addr } - if poolTx.ToBJJ != common.EmptyBJJComp { - toBJJ := common.BjjToString(poolTx.ToBJJ) - genSendTx.ToBJJ = &toBJJ + if poolTxs[i].ToBJJ != common.EmptyBJJComp { + toBJJ := common.BjjToString(poolTxs[i].ToBJJ) genReceiveTx.ToBJJ = &toBJJ - } else if poolTx.ToIdx > 255 { - acc := getAccountByIdx(poolTx.ToIdx, accs) + } else if poolTxs[i].ToIdx > 255 { + acc := getAccountByIdx(poolTxs[i].ToIdx, accs) bjj := common.BjjToString(acc.BJJ) genReceiveTx.ToBJJ = &bjj } - if poolTx.RqFromIdx != 0 { - rqFromIdx := common.IdxToHez(poolTx.RqFromIdx, token.Symbol) - genSendTx.RqFromIdx = &rqFromIdx + if poolTxs[i].RqFromIdx != 0 { + rqFromIdx := common.IdxToHez(poolTxs[i].RqFromIdx, rqToken.Symbol) genReceiveTx.RqFromIdx = &rqFromIdx - genSendTx.RqTokenID = &token.TokenID - genReceiveTx.RqTokenID = &token.TokenID - rqAmount := poolTx.RqAmount.String() - genSendTx.RqAmount = &rqAmount + genReceiveTx.RqTokenID = &rqToken.TokenID + rqAmount := poolTxs[i].RqAmount.String() genReceiveTx.RqAmount = &rqAmount + genReceiveTx.RqFee = &poolTxs[i].RqFee + genReceiveTx.RqNonce = &poolTxs[i].RqNonce - if poolTx.RqToIdx != 0 { - rqToIdx := common.IdxToHez(poolTx.RqToIdx, token.Symbol) - genSendTx.RqToIdx = &rqToIdx + if poolTxs[i].RqToIdx != 0 { + rqToIdx := common.IdxToHez(poolTxs[i].RqToIdx, rqToken.Symbol) genReceiveTx.RqToIdx = &rqToIdx } - if poolTx.RqToEthAddr != common.EmptyAddr { - rqToEth := common.EthAddrToHez(poolTx.RqToEthAddr) - genSendTx.RqToEthAddr = &rqToEth + if poolTxs[i].RqToEthAddr != common.EmptyAddr { + rqToEth := common.EthAddrToHez(poolTxs[i].RqToEthAddr) genReceiveTx.RqToEthAddr = &rqToEth } - if poolTx.RqToBJJ != common.EmptyBJJComp { - rqToBJJ := common.BjjToString(poolTx.RqToBJJ) - genSendTx.RqToBJJ = &rqToBJJ + if poolTxs[i].RqToBJJ != common.EmptyBJJComp { + rqToBJJ := common.BjjToString(poolTxs[i].RqToBJJ) genReceiveTx.RqToBJJ = &rqToBJJ } } - poolTxsToSend = append(poolTxsToSend, genSendTx) poolTxsToReceive = append(poolTxsToReceive, genReceiveTx) } return poolTxsToSend, poolTxsToReceive @@ -214,7 +169,7 @@ func TestPoolTxs(t *testing.T) { // 400 // Wrong fee badTx := tc.poolTxsToSend[0] - badTx.Amount = "99950000000000000" + badTx.Amount = big.NewInt(99950000000000000) badTx.Fee = 255 jsonTxBytes, err := json.Marshal(badTx) require.NoError(t, err) @@ -223,7 +178,7 @@ func TestPoolTxs(t *testing.T) { require.NoError(t, err) // Wrong signature badTx = tc.poolTxsToSend[0] - badTx.FromIdx = "hez:foo:1000" + badTx.FromIdx = 1000 jsonTxBytes, err = json.Marshal(badTx) require.NoError(t, err) jsonTxReader = bytes.NewReader(jsonTxBytes) @@ -231,9 +186,8 @@ func TestPoolTxs(t *testing.T) { require.NoError(t, err) // Wrong to badTx = tc.poolTxsToSend[0] - ethAddr := "hez:0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - badTx.ToEthAddr = ðAddr - badTx.ToIdx = nil + badTx.ToEthAddr = common.FFAddr + badTx.ToIdx = 0 jsonTxBytes, err = json.Marshal(badTx) require.NoError(t, err) jsonTxReader = bytes.NewReader(jsonTxBytes) @@ -241,8 +195,15 @@ func TestPoolTxs(t *testing.T) { require.NoError(t, err) // Wrong rq badTx = tc.poolTxsToSend[0] - rqFromIdx := "hez:foo:30" - badTx.RqFromIdx = &rqFromIdx + badTx.RqFromIdx = 30 + jsonTxBytes, err = json.Marshal(badTx) + require.NoError(t, err) + jsonTxReader = bytes.NewReader(jsonTxBytes) + err = doBadReq("POST", endpoint, jsonTxReader, 409) + require.NoError(t, err) + // Wrong maxNumBatch + badTx = tc.poolTxsToSend[0] + badTx.MaxNumBatch = 30 jsonTxBytes, err = json.Marshal(badTx) require.NoError(t, err) jsonTxReader = bytes.NewReader(jsonTxBytes) @@ -488,20 +449,12 @@ func assertPoolTx(t *testing.T, expected, actual testPoolTxReceive) { // TestAllTosNull test that the API doesn't accept txs with all the TOs set to null (to eth, to bjj, to idx) func TestAllTosNull(t *testing.T) { + // Generate keys + addr, sk := generateKeys(4444) // Generate account: - // Ethereum private key - var key ecdsa.PrivateKey - key.D = big.NewInt(int64(4444)) // only for testing - key.PublicKey.X, key.PublicKey.Y = ethCrypto.S256().ScalarBaseMult(key.D.Bytes()) - key.Curve = ethCrypto.S256() - addr := ethCrypto.PubkeyToAddress(key.PublicKey) - // BJJ private key - var sk babyjub.PrivateKey - var iBytes [8]byte - binary.LittleEndian.PutUint64(iBytes[:], 4444) - copy(sk[:], iBytes[:]) // only for testing + var testIdx common.Idx = 333 account := common.Account{ - Idx: 4444, + Idx: testIdx, TokenID: 0, BatchNum: 1, BJJ: sk.Public().Compress(), @@ -534,24 +487,17 @@ func TestAllTosNull(t *testing.T) { assert.NoError(t, err) sig := sk.SignPoseidon(toSign) tx.Signature = sig.Compress() - // Transform common.PoolL2Tx ==> testPoolTxSend - txToSend := testPoolTxSend{ - TxID: tx.TxID, - Type: tx.Type, - TokenID: tx.TokenID, - FromIdx: common.IdxToHez(tx.FromIdx, "ETH"), - Amount: tx.Amount.String(), - Fee: tx.Fee, - Nonce: tx.Nonce, - Signature: tx.Signature, - } + // Add token symbol for mashaling + tx.TokenSymbol = "ETH" // Send tx to the API - jsonTxBytes, err := json.Marshal(txToSend) + jsonTxBytes, err := json.Marshal(tx) require.NoError(t, err) jsonTxReader := bytes.NewReader(jsonTxBytes) err = doBadReq("POST", apiURL+"transactions-pool", jsonTxReader, 400) require.NoError(t, err) // Clean historyDB: the added account shouldn't be there for other tests - _, err = api.h.DB().DB.Exec("delete from account where idx = 4444") + _, err = api.h.DB().DB.Exec( + fmt.Sprintf("delete from account where idx = %d", testIdx), + ) assert.NoError(t, err) } diff --git a/cmd/heznode/README.md b/cmd/heznode/README.md index 39ad53d4d..34269cded 100644 --- a/cmd/heznode/README.md +++ b/cmd/heznode/README.md @@ -49,7 +49,7 @@ The node has two main modes of running: The node requires a single configuration file to run. You can find a testing working configuration example at -[cfg.buidler.toml](./cfg.buidler.toml) +[cfg.buidler.toml](cfg.builder.toml) To read the documentation of each configuration parameter, please check the `type Node` and `type Coordinator` at @@ -120,12 +120,12 @@ run the following examples by replacing `./dist/heznode` with `go run ./cmd/hezn Run the node in mode synchronizer: ```shell -./dist/heznode run --mode sync --cfg cfg.buidler.toml +./dist/heznode run --mode sync --cfg cfg.builder.toml ``` Run the node in mode coordinator: ```shell -./dist/heznode run --mode coord --cfg cfg.buidler.toml +./dist/heznode run --mode coord --cfg cfg.builder.toml ``` Serve the API in standalone mode. This command allows serving the API just @@ -133,12 +133,12 @@ with access to the PostgreSQL database that a node is using. Several instances of `serveapi` can be running at the same time with a single PostgreSQL database: ```shell -./dist/heznode serveapi --mode coord --cfg cfg.buidler.toml +./dist/heznode serveapi --mode coord --cfg cfg.builder.toml ``` Import an ethereum private key into the keystore: ```shell -./dist/heznode importkey --mode coord --cfg cfg.buidler.toml --privatekey 0x618b35096c477aab18b11a752be619f0023a539bb02dd6c813477a6211916cde +./dist/heznode importkey --mode coord --cfg cfg.builder.toml --privatekey 0x618b35096c477aab18b11a752be619f0023a539bb02dd6c813477a6211916cde ``` Generate a new random BabyJubJub key pair: @@ -154,7 +154,7 @@ Check the binary version: Wipe the entier SQL database (this will destroy all synchronized and pool data): ```shell -./dist/heznode wipedbs --mode coord --cfg cfg.buidler.toml +./dist/heznode wipedbs --mode coord --cfg cfg.builder.toml ``` Discard all synchronized blocks and associated state up to a given block @@ -162,7 +162,7 @@ number. This command is useful in case the synchronizer reaches an invalid state and you want to roll back a few blocks and try again (maybe with some fixes in the code). ```shell -./dist/heznode discard --mode coord --cfg cfg.buidler.toml --block 8061330 +./dist/heznode discard --mode coord --cfg cfg.builder.toml --block 8061330 ``` Read information about an account: diff --git a/cmd/heznode/cfg.buidler.toml b/cmd/heznode/cfg.builder.toml similarity index 97% rename from cmd/heznode/cfg.buidler.toml rename to cmd/heznode/cfg.builder.toml index dd2f16462..cde577ee3 100644 --- a/cmd/heznode/cfg.buidler.toml +++ b/cmd/heznode/cfg.builder.toml @@ -96,7 +96,7 @@ IgnoreSlotCommitment = false [Coordinator.FeeAccount] Address = "0x56232B1c5B10038125Bc7345664B4AFD745bcF8E" # PrivateKey = "0x3a9270c020e169097808da4b02e8d9100be0f8a38cfad3dcfc0b398076381fdd" -BJJ = "0x1b176232f78ba0d388ecc5f4896eca2d3b3d4f272092469f559247297f5c0c13" +BJJ = "0x130c5c7f294792559f469220274f3d3b2dca6e89f4c5ec88d3a08bf73262171b" # BJJPrivateKey = "0xb556862fb60e7cf4c0a8a7f44baf2ab06a4c90ac39decc4eef363b6142d07a34" [Coordinator.L2DB] @@ -129,7 +129,8 @@ Attempts = 4 AttemptsDelay = "500ms" TxResendTimeout = "2m" NoReuseNonce = false -MaxGasPrice = "5000000000" +MaxGasPrice = 2000 +MinGasPrice = 5 GasPriceIncPerc = 10 [Coordinator.EthClient.Keystore] diff --git a/cmd/heznode/main.go b/cmd/heznode/main.go index d3b664d3b..07e9a5907 100644 --- a/cmd/heznode/main.go +++ b/cmd/heznode/main.go @@ -7,12 +7,13 @@ import ( "os" "os/signal" "path" + "regexp" + "strconv" "strings" ethKeystore "github.com/ethereum/go-ethereum/accounts/keystore" + ethCommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/hermeznetwork/hermez-go-sdk/account" - "github.com/hermeznetwork/hermez-go-sdk/client" "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/config" dbUtils "github.com/hermeznetwork/hermez-node/db" @@ -28,17 +29,15 @@ import ( ) const ( - flagCfg = "cfg" - flagMode = "mode" - flagSK = "privatekey" - flagYes = "yes" - flagBlock = "block" - modeSync = "sync" - modeCoord = "coord" - nMigrations = "nMigrations" - flagAuctContractAddrHex = "auctContractAddrHex" - flagEthNodeURL = "ethNodeUrl" - flagAccountAddrHex = "accountAddrHex" + flagCfg = "cfg" + flagMode = "mode" + flagSK = "privatekey" + flagYes = "yes" + flagBlock = "block" + modeSync = "sync" + modeCoord = "coord" + nMigrations = "nMigrations" + flagAccount = "account" ) var ( @@ -317,31 +316,52 @@ func cmdServeAPI(c *cli.Context) error { } func cmdGetAccountDetails(c *cli.Context) error { - ethereumNodeURL := c.String(flagEthNodeURL) - auctionContractAddressHex := c.String(flagAuctContractAddrHex) - accountAddrHex := c.String(flagAccountAddrHex) - - hezClient, err := client.NewHermezClient(ethereumNodeURL, auctionContractAddressHex) + addr, bjj, accountIdxs, err := checkAccountParam(c) + if err != nil { + log.Error(err) + return nil + } + _cfg, err := parseCli(c) if err != nil { - log.Errorf("Error during Hermez client initialization: %s\n", err.Error()) - return err + return tracerr.Wrap(fmt.Errorf("error parsing flags and config: %w", err)) } - log.Infof("Connected to Hermez Smart Contracts...") - log.Infof("Pulling account info from a coordinator...") - accountDetails, err := account.GetAccountInfo(hezClient, accountAddrHex) + cfg := _cfg.node + + historyDB, err := openDBConexion(cfg) if err != nil { - log.Errorf("Error obtaining account details. Account: %s - Error: %s\n", accountAddrHex, err.Error()) - return err + log.Error(err) + return nil + } + + obj := historydb.GetAccountsAPIRequest{ + EthAddr: addr, + Bjj: bjj, + } + var apiAccounts []historydb.AccountAPI + if len(accountIdxs) == 0 { + apiAccounts, _, err = historyDB.GetAccountsAPI(obj) + if err != nil { + return tracerr.Wrap(fmt.Errorf("historyDB.GetAccountsAPI: %w", err)) + } + } else { + for i := 0; i < len(accountIdxs); i++ { + apiAccount, err := historyDB.GetAccountAPI(accountIdxs[i]) + if err != nil { + log.Debug(fmt.Errorf("historyDB.GetAccountAPI: %w", err)) + } else { + apiAccounts = append(apiAccounts, *apiAccount) + } + } } - log.Infof("Found %d account(s)", len(accountDetails.Accounts)) - for index, account := range accountDetails.Accounts { + log.Infof("Found %d account(s)", len(apiAccounts)) + for index, account := range apiAccounts { log.Infof("Details for account %d", index) - log.Infof(" - Account index: %s", account.AccountIndex) - log.Infof(" - Account BJJ : %s", account.BJJAddress) - log.Infof(" - Balance : %s", account.Balance) - log.Infof(" - HEZ Address : %s", account.HezEthereumAddress) - log.Infof(" - Token name : %s", account.Token.Name) - log.Infof(" - Token symbol : %s", account.Token.Symbol) + log.Infof(" - Account index: %s", account.Idx) + log.Infof(" - Account BJJ : %s", account.PublicKey) + log.Infof(" - Balance : %s", *account.Balance) + log.Infof(" - HEZ Address : %s", account.EthAddr) + log.Infof(" - Token name : %s", account.TokenName) + log.Infof(" - Token symbol : %s", account.TokenSymbol) } return nil } @@ -601,23 +621,12 @@ func main() { Aliases: []string{}, Usage: "get information about the specified account", Action: cmdGetAccountDetails, - Flags: []cli.Flag{ - &cli.StringFlag{ - Name: flagEthNodeURL, - Usage: "ethereum node URL, example: http://geth.node.com:8545", - Required: true, - }, - &cli.StringFlag{ - Name: flagAuctContractAddrHex, - Usage: "auction contract address in hex", - Required: true, - }, + Flags: append(flags, &cli.StringFlag{ - Name: flagAccountAddrHex, + Name: flagAccount, Usage: "account address in hex", Required: true, - }, - }, + }), }, } @@ -627,3 +636,70 @@ func main() { os.Exit(1) } } + +func checkAccountParam(c *cli.Context) (*ethCommon.Address, *babyjub.PublicKeyComp, []common.Idx, error) { + accountParam := c.String(flagAccount) + const characters = 42 + var ( + addr *ethCommon.Address + accountIdxs []common.Idx + bjj *babyjub.PublicKeyComp + err error + ) + matchIdx, _ := regexp.MatchString("^\\d+$", accountParam) + if strings.HasPrefix(accountParam, "0x") { //Check ethereum address + addr, err = common.HezStringToEthAddr("hez:"+accountParam, "hezEthereumAddress") + if err != nil { + return nil, nil, nil, err + } + } else if len(accountParam) > characters { //Check internal hermez account address + bjj, err = common.HezStringToBJJ(accountParam, "BJJ") + if err != nil { + return nil, nil, nil, err + } + } else if matchIdx { //Check tokenID + value, _ := strconv.Atoi(accountParam) + accountIdxs = append(accountIdxs, (common.Idx)(value)) + } else { + return nil, nil, nil, fmt.Errorf("invalid parameter. Only accepted ethereum address, bjj address or account index") + } + return addr, bjj, accountIdxs, nil +} + +func openDBConexion(cfg *config.Node) (*historydb.HistoryDB, error) { + dbWrite, err := dbUtils.InitSQLDB( + cfg.PostgreSQL.PortWrite, + cfg.PostgreSQL.HostWrite, + cfg.PostgreSQL.UserWrite, + cfg.PostgreSQL.PasswordWrite, + cfg.PostgreSQL.NameWrite, + ) + if err != nil { + return nil, tracerr.Wrap(fmt.Errorf("dbUtils.InitSQLDB: %w", err)) + } + var dbRead *sqlx.DB + if cfg.PostgreSQL.HostRead == "" { + dbRead = dbWrite + } else if cfg.PostgreSQL.HostRead == cfg.PostgreSQL.HostWrite { + return nil, tracerr.Wrap(fmt.Errorf( + "PostgreSQL.HostRead and PostgreSQL.HostWrite must be different", + )) + } else { + dbRead, err = dbUtils.InitSQLDB( + cfg.PostgreSQL.PortRead, + cfg.PostgreSQL.HostRead, + cfg.PostgreSQL.UserRead, + cfg.PostgreSQL.PasswordRead, + cfg.PostgreSQL.NameRead, + ) + if err != nil { + return nil, tracerr.Wrap(fmt.Errorf("dbUtils.InitSQLDB: %w", err)) + } + } + apiConnCon := dbUtils.NewAPIConnectionController( + cfg.API.MaxSQLConnections, + cfg.API.SQLConnectionTimeout.Duration, + ) + historyDB := historydb.NewHistoryDB(dbRead, dbWrite, apiConnCon) + return historyDB, nil +} diff --git a/common/accountcreationauths.go b/common/accountcreationauths.go index 5c0605a7f..5eca905de 100644 --- a/common/accountcreationauths.go +++ b/common/accountcreationauths.go @@ -1,6 +1,8 @@ package common import ( + "encoding/hex" + "fmt" "time" ethCommon "github.com/ethereum/go-ethereum/common" @@ -122,11 +124,15 @@ func (a *AccountCreationAuth) Sign(signHash func(hash []byte) ([]byte, error), // chainID and hermezContractAddress passed by parameter. VerifySignature // follows the EIP-712 encoding. func (a *AccountCreationAuth) VerifySignature(chainID uint16, - hermezContractAddr ethCommon.Address) bool { + hermezContractAddr ethCommon.Address) (bool, error) { // Calculate hash to be signed hash, err := a.HashToSign(chainID, hermezContractAddr) if err != nil { - return false + signatureV := hex.EncodeToString(a.Signature) + return false, fmt.Errorf("error calculating hash to be signed: %s. "+ + "ChainId: %d. HermezContractAddress: %s. EthereumAddress: %s. Bjj: %s. "+ + "Signature: %s. Timestamp: %s", err.Error(), chainID, hermezContractAddr.String(), + a.EthAddr.String(), BjjToString(a.BJJ), signatureV, a.Timestamp.String()) } var sig [65]byte @@ -136,13 +142,27 @@ func (a *AccountCreationAuth) VerifySignature(chainID uint16, // Get public key from Signature pubKBytes, err := ethCrypto.Ecrecover(hash, sig[:]) if err != nil { - return false + signatureV := hex.EncodeToString(a.Signature) + return false, fmt.Errorf("error getting public key from Signature: %s. "+ + "ChainId: %d. HermezContractAddress: %s. EthereumAddress: %s. Bjj: %s. "+ + "Signature: %s. Timestamp: %s", err.Error(), chainID, hermezContractAddr.String(), + a.EthAddr.String(), BjjToString(a.BJJ), signatureV, a.Timestamp.String()) } pubK, err := ethCrypto.UnmarshalPubkey(pubKBytes) if err != nil { - return false + signatureV := hex.EncodeToString(a.Signature) + return false, fmt.Errorf("error unmarshalling public key: %s. ChainId: %d. "+ + "HermezContractAddress: %s. EthereumAddress: %s. Bjj: %s. Signature: %s. "+ + "Timestamp: %s", err.Error(), chainID, hermezContractAddr.String(), + a.EthAddr.String(), BjjToString(a.BJJ), signatureV, a.Timestamp.String()) } // Get addr from pubK addr := ethCrypto.PubkeyToAddress(*pubK) - return addr == a.EthAddr + if addr != a.EthAddr { + signatureV := hex.EncodeToString(a.Signature) + return false, fmt.Errorf("error: Ethereum address doesn't match with the one used in the signature. "+ + "ChainId: %d. HermezContractAddress: %s. EthereumAddress: %s. Bjj: %s. Signature: %s. Timestamp: %s", + chainID, hermezContractAddr.String(), a.EthAddr.String(), BjjToString(a.BJJ), signatureV, a.Timestamp.String()) + } + return true, nil } diff --git a/common/accountcreationauths_test.go b/common/accountcreationauths_test.go index e7beea17b..c9f1ed662 100644 --- a/common/accountcreationauths_test.go +++ b/common/accountcreationauths_test.go @@ -46,8 +46,9 @@ func TestAccountCreationAuthSignVerify(t *testing.T) { require.NoError(t, err) sig[64] += 27 assert.Equal(t, sig, a.Signature) - - assert.True(t, a.VerifySignature(chainID, hermezContractAddr)) + isValid, err := a.VerifySignature(chainID, hermezContractAddr) + require.NoError(t, err) + assert.True(t, isValid) } func TestKeccak256JSComp(t *testing.T) { @@ -143,7 +144,8 @@ func TestAccountCreationAuthJSComp(t *testing.T) { assert.Equal(t, tv.sigExpected, hex.EncodeToString(sig)) a.Signature = sig - - assert.True(t, a.VerifySignature(chainID, hermezContractAddr)) + isValid, err := a.VerifySignature(chainID, hermezContractAddr) + require.NoError(t, err) + assert.True(t, isValid) } } diff --git a/common/atomic.go b/common/atomic.go new file mode 100644 index 000000000..3d0dd60b1 --- /dev/null +++ b/common/atomic.go @@ -0,0 +1,117 @@ +package common + +import ( + "database/sql/driver" + "encoding/hex" + "errors" + "fmt" + "strings" + + ethCrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/hermeznetwork/tracerr" +) + +// AtomicGroupIDLen is the length of a Hermez network atomic group +const AtomicGroupIDLen = 32 + +// AtomicGroupID is the identifier of a Hermez network atomic group +type AtomicGroupID [AtomicGroupIDLen]byte + +// EmptyAtomicGroupID represents an empty Hermez network atomic group identifier +var EmptyAtomicGroupID = AtomicGroupID([32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) + +// CalculateAtomicGroupID calculates the atomic group ID given the identifiers of +// the transactions that conform the atomic group +func CalculateAtomicGroupID(txIDs []TxID) AtomicGroupID { + txIDConcatenation := make([]byte, TxIDLen*len(txIDs)) + for i, id := range txIDs { + idBytes := [TxIDLen]byte(id) + copy(txIDConcatenation[i*TxIDLen:(i+1)*TxIDLen], idBytes[:]) + } + h := ethCrypto.Keccak256Hash(txIDConcatenation).Bytes() + var agid AtomicGroupID + copy(agid[:], h) + return agid +} + +// Scan implements Scanner for database/sql. +func (agid *AtomicGroupID) Scan(src interface{}) error { + srcB, ok := src.([]byte) + if !ok { + return tracerr.Wrap(fmt.Errorf("can't scan %T into AtomicGroupID", src)) + } + if len(srcB) != AtomicGroupIDLen { + return tracerr.Wrap(fmt.Errorf("can't scan []byte of len %d into AtomicGroupID, need %d", + len(srcB), AtomicGroupIDLen)) + } + copy(agid[:], srcB) + return nil +} + +// Value implements valuer for database/sql. +func (agid AtomicGroupID) Value() (driver.Value, error) { + return agid[:], nil +} + +// String returns a string hexadecimal representation of the AtomicGroupID +func (agid AtomicGroupID) String() string { + return "0x" + hex.EncodeToString(agid[:]) +} + +// NewAtomicGroupIDFromString returns a string hexadecimal representation of the AtomicGroupID +func NewAtomicGroupIDFromString(idStr string) (AtomicGroupID, error) { + agid := AtomicGroupID{} + idStr = strings.TrimPrefix(idStr, "0x") + decoded, err := hex.DecodeString(idStr) + if err != nil { + return AtomicGroupID{}, tracerr.Wrap(err) + } + if len(decoded) != AtomicGroupIDLen { + return agid, tracerr.Wrap(errors.New("Invalid idStr")) + } + copy(agid[:], decoded) + return agid, nil +} + +// MarshalText marshals a AtomicGroupID +func (agid AtomicGroupID) MarshalText() ([]byte, error) { + return []byte(agid.String()), nil +} + +// UnmarshalText unmarshalls a AtomicGroupID +func (agid *AtomicGroupID) UnmarshalText(data []byte) error { + idStr := string(data) + id, err := NewAtomicGroupIDFromString(idStr) + if err != nil { + return tracerr.Wrap(err) + } + *agid = id + return nil +} + +// AtomicGroup represents a set of atomic transactions +type AtomicGroup struct { + ID AtomicGroupID `json:"atomicGroupId"` + Txs []PoolL2Tx `json:"transactions"` +} + +// SetAtomicGroupID set the atomic group ID for an atomic group that already has Txs +func (ag *AtomicGroup) SetAtomicGroupID() { + ids := []TxID{} + for _, tx := range ag.Txs { + ids = append(ids, tx.TxID) + } + ag.ID = CalculateAtomicGroupID(ids) +} + +// IsAtomicGroupIDValid return false if the atomic group ID that is set +// doesn't match with the calculated +func (ag AtomicGroup) IsAtomicGroupIDValid() bool { + ids := []TxID{} + for _, tx := range ag.Txs { + ids = append(ids, tx.TxID) + } + actualAGID := CalculateAtomicGroupID(ids) + return actualAGID == ag.ID +} diff --git a/common/converters.go b/common/converters.go index ee32b338d..df9b360e2 100644 --- a/common/converters.go +++ b/common/converters.go @@ -3,6 +3,7 @@ package common import ( "encoding/base64" "fmt" + "math/big" "strconv" "strings" @@ -47,21 +48,26 @@ func StringToL2TxState(txState string) (*PoolL2TxState, error) { } } +// QueryAccount is a representation of an account with accountIndex and its token symbol +type QueryAccount struct { + AccountIndex *Idx + Symbol string +} + // StringToIdx converts string to account index -func StringToIdx(idxStr, name string) (*Idx, error) { +func StringToIdx(idxStr, name string) (QueryAccount, error) { if idxStr == "" { - return nil, nil + return QueryAccount{}, nil } splitted := strings.Split(idxStr, ":") const expectedLen = 3 if len(splitted) != expectedLen || splitted[0] != "hez" { - return nil, tracerr.Wrap(fmt.Errorf( + return QueryAccount{}, tracerr.Wrap(fmt.Errorf( "invalid %s, must follow this: hez::index", name)) } - // TODO: check that the tokenSymbol match the token related to the account index idxInt, err := strconv.Atoi(splitted[2]) idx := Idx(idxInt) - return &idx, tracerr.Wrap(err) + return QueryAccount{AccountIndex: &idx, Symbol: splitted[1]}, tracerr.Wrap(err) } // HezStringToEthAddr converts hez ethereum address to ethereum address @@ -146,3 +152,76 @@ func EthAddrToHez(addr ethCommon.Address) string { func IdxToHez(idx Idx, tokenSymbol string) string { return "hez:" + tokenSymbol + ":" + strconv.Itoa(int(idx)) } + +// StrHezIdx is used to unmarshal HezIdx directly into an alias of Idx +type StrHezIdx struct { + Idx Idx + TokenSymbol string +} + +// UnmarshalText unmarshals a StrHezIdx +func (s *StrHezIdx) UnmarshalText(text []byte) error { + withoutHez := strings.TrimPrefix(string(text), "hez:") + splitted := strings.Split(withoutHez, ":") + const expectedLen = 2 + if len(splitted) != expectedLen { + return tracerr.Wrap(fmt.Errorf("can not unmarshal %s into StrHezIdx", text)) + } + idxInt, err := strconv.Atoi(splitted[1]) + if err != nil { + return tracerr.Wrap(err) + } + *s = StrHezIdx{ + Idx: Idx(idxInt), + TokenSymbol: splitted[0], + } + return nil +} + +// StrHezEthAddr is used to unmarshal HezEthAddr directly into an alias of ethCommon.Address +type StrHezEthAddr ethCommon.Address + +// UnmarshalText unmarshals a StrHezEthAddr +func (s *StrHezEthAddr) UnmarshalText(text []byte) error { + if len(text) == 0 { + *s = StrHezEthAddr(EmptyAddr) + return nil + } + withoutHez := strings.TrimPrefix(string(text), "hez:") + var addr ethCommon.Address + if err := addr.UnmarshalText([]byte(withoutHez)); err != nil { + return tracerr.Wrap(err) + } + *s = StrHezEthAddr(addr) + return nil +} + +// StrHezBJJ is used to unmarshal HezBJJ directly into an alias of babyjub.PublicKeyComp +type StrHezBJJ babyjub.PublicKeyComp + +// UnmarshalText unmarshalls a StrHezBJJ +func (s *StrHezBJJ) UnmarshalText(text []byte) error { + if len(text) == 0 { + *s = StrHezBJJ(EmptyBJJComp) + return nil + } + bjj, err := HezStringToBJJ(string(text), "") + if err != nil { + return tracerr.Wrap(err) + } + *s = StrHezBJJ(*bjj) + return nil +} + +// StrBigInt is used to unmarshal BigIntStr directly into an alias of big.Int +type StrBigInt big.Int + +// UnmarshalText unmarshals a StrBigInt +func (s *StrBigInt) UnmarshalText(text []byte) error { + bi, ok := (*big.Int)(s).SetString(string(text), 10) + if !ok { + return tracerr.Wrap(fmt.Errorf("could not unmarshal %s into a StrBigInt", text)) + } + *s = StrBigInt(*bi) + return nil +} diff --git a/common/converters_test.go b/common/converters_test.go new file mode 100644 index 000000000..6add93b4e --- /dev/null +++ b/common/converters_test.go @@ -0,0 +1,80 @@ +package common + +import ( + "database/sql" + "encoding/json" + "io/ioutil" + "math/big" + "os" + "testing" + + ethCommon "github.com/ethereum/go-ethereum/common" + dbUtils "github.com/hermeznetwork/hermez-node/db" + + // nolint sqlite driver + _ "github.com/mattn/go-sqlite3" + "github.com/russross/meddler" + "github.com/stretchr/testify/assert" +) + +var db *sql.DB + +func TestMain(m *testing.M) { + // Register meddler + meddler.Default = meddler.SQLite + meddler.Register("bigint", dbUtils.BigIntMeddler{}) + meddler.Register("bigintnull", dbUtils.BigIntNullMeddler{}) + // Create temporary sqlite DB + dir, err := ioutil.TempDir("", "db") + if err != nil { + panic(err) + } + db, err = sql.Open("sqlite3", dir+"sqlite.db") + if err != nil { + panic(err) + } + defer os.RemoveAll(dir) //nolint + schema := `CREATE TABLE test (i BLOB);` + if _, err := db.Exec(schema); err != nil { + panic(err) + } + // Run tests + result := m.Run() + os.Exit(result) +} + +func TestStrBigInt(t *testing.T) { + type testStrBigInt struct { + I StrBigInt + } + from := []byte(`{"I":"4"}`) + to := &testStrBigInt{} + assert.NoError(t, json.Unmarshal(from, to)) + assert.Equal(t, big.NewInt(4), (*big.Int)(&to.I)) +} + +func TestStrHezEthAddr(t *testing.T) { + type testStrHezEthAddr struct { + I StrHezEthAddr + } + withoutHez := "0xaa942cfcd25ad4d90a62358b0dd84f33b398262a" + from := []byte(`{"I":"hez:` + withoutHez + `"}`) + var addr ethCommon.Address + if err := addr.UnmarshalText([]byte(withoutHez)); err != nil { + panic(err) + } + to := &testStrHezEthAddr{} + assert.NoError(t, json.Unmarshal(from, to)) + assert.Equal(t, addr, ethCommon.Address(to.I)) +} + +func TestStrHezIdx(t *testing.T) { + type testStrHezIdx struct { + I StrHezIdx + } + from := []byte(`{"I":"hez:foo:4"}`) + to := &testStrHezIdx{} + assert.NoError(t, json.Unmarshal(from, to)) + assert.Equal(t, Idx(4), Idx(to.I.Idx)) + assert.Equal(t, "foo", to.I.TokenSymbol) +} diff --git a/common/pooll2tx.go b/common/pooll2tx.go index 88fa492cf..d93f63512 100644 --- a/common/pooll2tx.go +++ b/common/pooll2tx.go @@ -2,6 +2,7 @@ package common import ( "encoding/binary" + "encoding/json" "errors" "fmt" "math/big" @@ -33,22 +34,26 @@ type PoolL2Tx struct { // AuxToIdx is only used internally at the StateDB to avoid repeated // computation when processing transactions (from Synchronizer, // TxSelector, BatchBuilder) - AuxToIdx Idx `meddler:"-"` - ToEthAddr ethCommon.Address `meddler:"to_eth_addr,zeroisnull"` - ToBJJ babyjub.PublicKeyComp `meddler:"to_bjj,zeroisnull"` - TokenID TokenID `meddler:"token_id"` - Amount *big.Int `meddler:"amount,bigint"` - Fee FeeSelector `meddler:"fee"` - Nonce Nonce `meddler:"nonce"` // effective 40 bits used - State PoolL2TxState `meddler:"state"` + AuxToIdx Idx `meddler:"-"` + ToEthAddr ethCommon.Address `meddler:"to_eth_addr,zeroisnull"` + ToBJJ babyjub.PublicKeyComp `meddler:"to_bjj,zeroisnull"` + TokenID TokenID `meddler:"token_id"` + Amount *big.Int `meddler:"amount,bigint"` + Fee FeeSelector `meddler:"fee"` + Nonce Nonce `meddler:"nonce"` // effective 40 bits used + State PoolL2TxState `meddler:"state"` + MaxNumBatch uint32 `meddler:"max_num_batch,zeroisnull"` // Info contains information about the status & State of the // transaction. As for example, if the Tx has not been selected in the // last batch due not enough Balance at the Sender account, this reason // would appear at this parameter. Info string `meddler:"info,zeroisnull"` + ErrorCode int `meddler:"error_code,zeroisnull"` + ErrorType string `meddler:"error_type,zeroisnull"` Signature babyjub.SignatureComp `meddler:"signature"` // tx signature Timestamp time.Time `meddler:"timestamp,utctime"` // time when added to the tx pool // Stored in DB: optional fileds, may be uninitialized + AtomicGroupID AtomicGroupID `meddler:"atomic_group_id,zeroisnull"` RqFromIdx Idx `meddler:"rq_from_idx,zeroisnull"` RqToIdx Idx `meddler:"rq_to_idx,zeroisnull"` RqToEthAddr ethCommon.Address `meddler:"rq_to_eth_addr,zeroisnull"` @@ -60,8 +65,19 @@ type PoolL2Tx struct { AbsoluteFee float64 `meddler:"fee_usd,zeroisnull"` AbsoluteFeeUpdate time.Time `meddler:"usd_update,utctimez"` Type TxType `meddler:"tx_type"` + RqOffset uint8 `meddler:"rq_offset,zeroisnull"` // (max 3 bits) + // Extra DB write fields (not included in JSON) + ClientIP string `meddler:"client_ip"` // Extra metadata, may be uninitialized RqTxCompressedData []byte `meddler:"-"` // 253 bits, optional for atomic txs + TokenSymbol string `meddler:"-"` // Used for JSON marshaling the ToIdx +} + +// TxSelectorError struct that gives more details about the error +type TxSelectorError struct { + Message string `meddler:"info,zeroisnull"` + Code int `meddler:"error_code,zeroisnull"` + Type string `meddler:"error_type,zeroisnull"` } // NewPoolL2Tx returns the given L2Tx with the TxId & Type parameters calculated @@ -246,12 +262,19 @@ func (tx *PoolL2Tx) TxCompressedDataV2() (*big.Int, error) { // [ 48 bits ] rqFromIdx // 6 bytes // Total bits compressed data: 217 bits // 28 bytes in *big.Int representation func (tx *PoolL2Tx) RqTxCompressedDataV2() (*big.Int, error) { + var amountFloat40 Float40 if tx.RqAmount == nil { - tx.RqAmount = big.NewInt(0) - } - amountFloat40, err := NewFloat40(tx.RqAmount) - if err != nil { - return nil, tracerr.Wrap(err) + af40, err := NewFloat40(big.NewInt(0)) + if err != nil { + return nil, tracerr.Wrap(err) + } + amountFloat40 = af40 + } else { + af40, err := NewFloat40(tx.RqAmount) + if err != nil { + return nil, tracerr.Wrap(err) + } + amountFloat40 = af40 } amountFloat40Bytes, err := amountFloat40.Bytes() if err != nil { @@ -298,8 +321,10 @@ func (tx *PoolL2Tx) HashToSign(chainID uint16) (*big.Int, error) { return nil, tracerr.Wrap(err) } - // e1: [5 bytes AmountFloat40 | 20 bytes ToEthAddr] - var e1B [25]byte + // e1: [4 bytes MaxBatchNum | 5 bytes AmountFloat40 | 20 bytes ToEthAddr] + var e1B [29]byte + maxNumBatchBytes := make([]byte, 4) + binary.BigEndian.PutUint32(maxNumBatchBytes, tx.MaxNumBatch) amountFloat40, err := NewFloat40(tx.Amount) if err != nil { return nil, tracerr.Wrap(err) @@ -308,8 +333,9 @@ func (tx *PoolL2Tx) HashToSign(chainID uint16) (*big.Int, error) { if err != nil { return nil, tracerr.Wrap(err) } - copy(e1B[0:5], amountFloat40Bytes) - copy(e1B[5:25], tx.ToEthAddr[:]) + copy(e1B[0:4], maxNumBatchBytes) + copy(e1B[4:9], amountFloat40Bytes) + copy(e1B[9:29], tx.ToEthAddr[:]) e1 := new(big.Int).SetBytes(e1B[:]) rqToEthAddr := EthAddrToBigInt(tx.RqToEthAddr) @@ -410,3 +436,124 @@ const ( // PoolL2TxStateInvalid represents a L2Tx that has been invalidated PoolL2TxStateInvalid PoolL2TxState = "invl" ) + +// IsValid returns true if matches one of the supported PoolL2TxState +func (s PoolL2TxState) IsValid() bool { + switch s { + case PoolL2TxStatePending, PoolL2TxStateForging, PoolL2TxStateForged, PoolL2TxStateInvalid: + return true + default: + return false + } +} + +// MarshalJSON formats a PoolL2Tx in the expected JSON defined by the API, +// this format is specified in `api/swagger.yml:schemas/PostPoolL2Transaction` +func (tx PoolL2Tx) MarshalJSON() ([]byte, error) { + if tx.TokenSymbol == "" { + return nil, errors.New("Invalid tx.TokenSymbol") + } + type jsonFormat struct { + TxID TxID `json:"id"` + Type TxType `json:"type"` + TokenID TokenID `json:"tokenId"` + FromIdx string `json:"fromAccountIndex"` + ToIdx *string `json:"toAccountIndex"` + ToEthAddr *string `json:"toHezEthereumAddress"` + ToBJJ *string `json:"toBjj"` + Amount string `json:"amount"` + Fee FeeSelector `json:"fee"` + Nonce Nonce `json:"nonce"` + MaxNumBatch uint32 `json:"maxNumBatch"` + Signature babyjub.SignatureComp `json:"signature"` + RqOffset *uint8 `json:"requestOffset"` + } + // Set fields that do not require extra logic + toMarshal := jsonFormat{ + TxID: tx.TxID, + Type: tx.Type, + TokenID: tx.TokenID, + FromIdx: IdxToHez(tx.FromIdx, tx.TokenSymbol), + Amount: tx.Amount.String(), + Fee: tx.Fee, + Nonce: tx.Nonce, + MaxNumBatch: tx.MaxNumBatch, + Signature: tx.Signature, + } + // Set To fields + if tx.ToIdx != 0 { + toIdx := IdxToHez(tx.ToIdx, tx.TokenSymbol) + toMarshal.ToIdx = &toIdx + } + if tx.ToEthAddr != EmptyAddr { + toEth := EthAddrToHez(tx.ToEthAddr) + toMarshal.ToEthAddr = &toEth + } + if tx.ToBJJ != EmptyBJJComp { + toBJJ := BjjToString(tx.ToBJJ) + toMarshal.ToBJJ = &toBJJ + } + // Check if is a atomic and require another tx + if tx.RqFromIdx != 0 { + toMarshal.RqOffset = &tx.RqOffset + } + return json.Marshal(toMarshal) +} + +// UnmarshalJSON unmarshals a PoolL2Tx that has been formated in json as specified in `api/swagger.yml:schemas/PostPoolL2Transaction`. +// Note that ClientIP is not included as part of the json and will be set to "". +// If State is not setted (State == ""), it will be set to PoolL2TxStatePending. +func (tx *PoolL2Tx) UnmarshalJSON(data []byte) error { + receivedJSON := struct { + TxID TxID `json:"id" binding:"required"` + Type TxType `json:"type" binding:"required"` + TokenID TokenID `json:"tokenId"` + FromIdx StrHezIdx `json:"fromAccountIndex" binding:"required"` + ToIdx StrHezIdx `json:"toAccountIndex"` + ToEthAddr StrHezEthAddr `json:"toHezEthereumAddress"` + ToBJJ StrHezBJJ `json:"toBjj"` + Amount *StrBigInt `json:"amount" binding:"required"` + Fee FeeSelector `json:"fee"` + Nonce Nonce `json:"nonce"` + MaxNumBatch uint32 `json:"maxNumBatch"` + Signature babyjub.SignatureComp `json:"signature" binding:"required"` + State string `json:"state"` + RqOffset uint8 `json:"requestOffset"` + Info *string `json:"info"` + }{} + if err := json.Unmarshal(data, &receivedJSON); err != nil { + return err + } + // Check state + state := PoolL2TxStatePending + if receivedJSON.State != "" { + state = PoolL2TxState(receivedJSON.State) + if !state.IsValid() { + return fmt.Errorf("Invalid state: %s", state) + } + } + var info string + if receivedJSON.Info != nil { + info = *receivedJSON.Info + } + // Set values to destination struct + *tx = PoolL2Tx{ + TxID: receivedJSON.TxID, + FromIdx: Idx(receivedJSON.FromIdx.Idx), + ToIdx: Idx(receivedJSON.ToIdx.Idx), + ToEthAddr: ethCommon.Address(receivedJSON.ToEthAddr), + ToBJJ: babyjub.PublicKeyComp(receivedJSON.ToBJJ), + TokenID: receivedJSON.TokenID, + Amount: (*big.Int)(receivedJSON.Amount), + Fee: receivedJSON.Fee, + Nonce: receivedJSON.Nonce, + MaxNumBatch: receivedJSON.MaxNumBatch, + Signature: receivedJSON.Signature, + Type: receivedJSON.Type, + State: state, + TokenSymbol: receivedJSON.FromIdx.TokenSymbol, + RqOffset: receivedJSON.RqOffset, + Info: info, + } + return nil +} diff --git a/common/pooll2tx_test.go b/common/pooll2tx_test.go index 62e92297a..a1c35c90a 100644 --- a/common/pooll2tx_test.go +++ b/common/pooll2tx_test.go @@ -358,3 +358,33 @@ func TestPoolL2Tx_SetType(t *testing.T) { }) } } + +func TestHashMaxNumBatch(t *testing.T) { + toBJJ, err := HezStringToBJJ("hez:xut2umeShR_Lmquf3wjnbT7j_p-5T9qZ24Iewr4KUR8W", "") + require.NoError(t, err) + rqToBJJ, err := HezStringToBJJ("hez:JjTLlgy5ZcPIudKBNX_ejAJMT3jA-dYqC1FhHgvlyQsH", "") + require.NoError(t, err) + amount := big.NewInt(0) + amount.SetString("5300000000000000000", 10) + tx := PoolL2Tx{ + FromIdx: 439, + ToIdx: 825429, + ToEthAddr: ethCommon.HexToAddress("0xf4e2b0fcbd0dc4b326d8a52b718a7bb43bdbd072"), + ToBJJ: *toBJJ, + Amount: amount, + TokenID: 1, + Nonce: 6, + Fee: 226, + RqFromIdx: 227051877307886, + RqToIdx: 350, + RqToEthAddr: ethCommon.HexToAddress("0x4a4547136a017c665fcedcdddca9dfd6d7dbc77f"), + RqToBJJ: *rqToBJJ, + MaxNumBatch: 16385, + } + chainID := uint16(1) + toSign, err := tx.HashToSign(chainID) + assert.NoError(t, err) + assert.Equal(t, + "06226f6b16dc853fa8225e82e5fd675f51858e7cd6b3a951c169ac01d7125c71", + hex.EncodeToString(toSign.Bytes())) +} diff --git a/common/tx.go b/common/tx.go index 6452c8907..449c7be57 100644 --- a/common/tx.go +++ b/common/tx.go @@ -39,6 +39,10 @@ var ( // format, which is equivalent to 3322668559 as uint32 in byte array in // big endian representation. SignatureConstantBytes = []byte{198, 11, 230, 15} + + // EmptyTxID is used to check if a TxID is 0 + EmptyTxID = TxID([TxIDLen]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) ) // TxID is the identifier of a Hermez network transaction diff --git a/common/zk.go b/common/zk.go index 1447a3850..f4bc90566 100644 --- a/common/zk.go +++ b/common/zk.go @@ -126,7 +126,17 @@ type ZKInputs struct { // // RqOffset relative transaction position to be linked. Used to perform - // atomic transactions. + // atomic transactions. The format works like this: + // rqTxOffset | relativeIndex + // ---------------------------------------- + // 0 | no linked transaction + // 1 | 1 + // 2 | 2 + // 3 | 3 + // 4 | -4 + // 5 | -3 + // 6 | -2 + // 7 | -1 RqOffset []*big.Int `json:"rqOffset"` // uint8 (max 3 bits), len: [maxTx] // transaction L2 request data diff --git a/config/config.go b/config/config.go index aaec388e8..5448c17ca 100644 --- a/config/config.go +++ b/config/config.go @@ -192,7 +192,9 @@ type Coordinator struct { EthClient struct { // MaxGasPrice is the maximum gas price allowed for ethereum // transactions - MaxGasPrice *big.Int `validate:"required"` + MaxGasPrice int64 `validate:"required"` + // MinGasPrice is the minimum gas price in gwei allowed for ethereum + MinGasPrice int64 `validate:"required"` // GasPriceIncPerc is the percentage increase of gas price set // in an ethereum transaction from the suggested gas price by // the ethereum node diff --git a/coordinator/coordinator.go b/coordinator/coordinator.go index 80c5dfeca..12714eeec 100644 --- a/coordinator/coordinator.go +++ b/coordinator/coordinator.go @@ -154,9 +154,11 @@ type Config struct { // EthNoReuseNonce disables reusing nonces of pending transactions for // new replacement transactions EthNoReuseNonce bool - // MaxGasPrice is the maximum gas price allowed for ethereum + // MaxGasPrice is the maximum gas price in gwei allowed for ethereum // transactions - MaxGasPrice *big.Int + MaxGasPrice int64 + // MinGasPrice is the minimum gas price in gwei allowed for ethereum + MinGasPrice int64 // GasPriceIncPerc is the percentage increase of gas price set in an // ethereum transaction from the suggested gas price by the ehtereum // node @@ -391,7 +393,7 @@ func canForge(auctionConstants *common.AuctionConstants, auctionVars *common.Auc if slot.Forger == addr || (anyoneForge && mustForgeAtDeadline) { return true } - log.Debugw("canForge: can't forge", "slot.Forger", slot.Forger) + log.Debugw("canForge: can't forge because you didn't win the auction. Current slot auction winner: ", "slot.Forger", slot.Forger) return false } diff --git a/coordinator/coordinator_test.go b/coordinator/coordinator_test.go index dc6be0a98..7f6de58c1 100644 --- a/coordinator/coordinator_test.go +++ b/coordinator/coordinator_test.go @@ -115,12 +115,12 @@ func newTestModules(t *testing.T) modules { var bjj babyjub.PublicKeyComp err = bjj.UnmarshalText([]byte("c433f7a696b7aa3a5224efb3993baf0ccd9e92eecee0c29a3f6c8208a9e81d9e")) require.NoError(t, err) - coordAccount := &txselector.CoordAccount{ // TODO TMP + coordAccount := txselector.CoordAccount{ // TODO TMP Addr: ethCommon.HexToAddress("0xc58d29fA6e86E4FAe04DDcEd660d45BCf3Cb2370"), BJJ: bjj, AccountCreationAuth: nil, } - txSelector, err := txselector.NewTxSelector(coordAccount, txSelDBPath, syncStateDB, l2DB) + txSelector, err := txselector.NewTxSelector(&coordAccount, txSelDBPath, syncStateDB, l2DB) assert.NoError(t, err) batchBuilderDBPath, err = ioutil.TempDir("", "tmpBatchBuilderDB") diff --git a/coordinator/txmanager.go b/coordinator/txmanager.go index 8ce51f834..7aba96482 100644 --- a/coordinator/txmanager.go +++ b/coordinator/txmanager.go @@ -131,16 +131,9 @@ func (t *TxManager) syncSCVars(vars common.SCVariablesPtr) { // NewAuth generates a new auth object for an ethereum transaction func (t *TxManager) NewAuth(ctx context.Context, batchInfo *BatchInfo) (*bind.TransactOpts, error) { // First we try getting the gas price from etherscan. Later we get the gas price from the ethereum node. - var err error - // If gas price is higher than 2000, probably we are going to get the gasLimit exceed error - const maxGasPrice = 2000 - // If gas price is to low, probably there is an error or at Etherscan or Ethereum node. - // So setting a minimum value - const minGasPrice = 5 - - eGasPrice := big.NewInt(minGasPrice) + eGasPrice := big.NewInt(t.cfg.MinGasPrice) if t.etherscanService != nil { etherscanGasPrice, err := t.etherscanService.GetGasPrice(ctx) @@ -160,8 +153,8 @@ func (t *TxManager) NewAuth(ctx context.Context, batchInfo *BatchInfo) (*bind.Tr return nil, tracerr.Wrap(err) } - maxGasPriceBig := big.NewInt(maxGasPrice) - minGasPriceBig := big.NewInt(minGasPrice) + maxGasPriceBig := big.NewInt(t.cfg.MaxGasPrice) + minGasPriceBig := big.NewInt(t.cfg.MinGasPrice) if eGasPrice.Cmp(maxGasPriceBig) == 1 { eGasPrice = maxGasPriceBig @@ -264,7 +257,9 @@ func (t *TxManager) sendRollupForgeBatch(ctx context.Context, batchInfo *BatchIn } auth.Context = ctx for attempt := 0; attempt < t.cfg.EthClientAttempts; attempt++ { - if auth.GasPrice.Cmp(t.cfg.MaxGasPrice) > 0 { + maxGasPrice := big.NewInt(t.cfg.MaxGasPrice) + maxGasPrice.Mul(maxGasPrice, big.NewInt(params.GWei)) + if auth.GasPrice.Cmp(maxGasPrice) > 0 { return tracerr.Wrap(fmt.Errorf("calculated gasPrice (%v) > maxGasPrice (%v)", auth.GasPrice, t.cfg.MaxGasPrice)) } diff --git a/db/historydb/apiqueries.go b/db/historydb/apiqueries.go index 329f6b9fb..dc53c04d1 100644 --- a/db/historydb/apiqueries.go +++ b/db/historydb/apiqueries.go @@ -371,9 +371,10 @@ func (hdb *HistoryDB) GetTokenAPI(tokenID common.TokenID) (*TokenWithUSD, error) // GetTokensAPIRequest is an API request struct for getting tokens type GetTokensAPIRequest struct { - Ids []common.TokenID - Symbols []string - Name string + Ids []common.TokenID + Symbols []string + Name string + Addresses []ethCommon.Address FromItem *uint Limit *uint @@ -420,6 +421,16 @@ func (hdb *HistoryDB) GetTokensAPI( args = append(args, request.Name) nextIsAnd = true } + if len(request.Addresses) > 0 { + if nextIsAnd { + queryStr += "AND " + } else { + queryStr += "WHERE " + } + queryStr += "eth_addr IN (?) " + args = append(args, request.Addresses) + nextIsAnd = true + } if request.FromItem != nil { if nextIsAnd { queryStr += "AND " @@ -1091,7 +1102,9 @@ func (hdb *HistoryDB) GetAccountsAPI( } else { queryStr += " DESC " } - queryStr += fmt.Sprintf("LIMIT %d;", *request.Limit) + if request.Limit != nil { + queryStr += fmt.Sprintf("LIMIT %d;", *request.Limit) + } query, argsQ, err := sqlx.In(queryStr, args...) if err != nil { return nil, 0, tracerr.Wrap(err) @@ -1152,29 +1165,6 @@ func (hdb *HistoryDB) GetCommonAccountAPI(idx common.Idx) (*common.Account, erro }, nil } -// CanSendToEthAddr returns true if it's possible to send a tx to an Eth addr -// either because there is an idx associated to the Eth addr and token -// or the cordinator has an authorization to create a valid account -func (hdb *HistoryDB) CanSendToEthAddr(ethAddr ethCommon.Address, tokenID common.TokenID) (bool, error) { - cancel, err := hdb.apiConnCon.Acquire() - defer cancel() - if err != nil { - return false, tracerr.Wrap(err) - } - defer hdb.apiConnCon.Release() - - row := hdb.dbRead.QueryRow( - `SELECT ( - SELECT COUNT(*) > 0 FROM account WHERE eth_addr = $1 AND token_id = $2 LIMIT 1 - ) OR ( - SELECT COUNT(*) > 0 FROM account_creation_auth WHERE eth_addr = $1 LIMIT 1 - );`, - ethAddr, tokenID, - ) - var ok bool - return ok, tracerr.Wrap(row.Scan(&ok)) -} - // GetCoordinatorAPI returns a coordinator by its bidderAddr func (hdb *HistoryDB) GetCoordinatorAPI(bidderAddr ethCommon.Address) (*CoordinatorAPI, error) { cancel, err := hdb.apiConnCon.Acquire() diff --git a/db/historydb/historydb_test.go b/db/historydb/historydb_test.go index a1a3c931b..19e1f6bd7 100644 --- a/db/historydb/historydb_test.go +++ b/db/historydb/historydb_test.go @@ -385,25 +385,6 @@ func TestAccounts(t *testing.T) { fetchedAccBalances, err := historyDB.GetAllAccountUpdates() require.NoError(t, err) assert.Equal(t, accUpdates, fetchedAccBalances) - - // Test if can send to EthAddr for created accounts - var ok bool - for _, acc := range fetchedAccs { - // can send to created accounts - ok, err = historyDBWithACC.CanSendToEthAddr(acc.EthAddr, acc.TokenID) - require.NoError(t, err) - assert.True(t, ok) - - // cannot send to wrong tokenID - ok, err = historyDBWithACC.CanSendToEthAddr(acc.EthAddr, 0) - require.NoError(t, err) - assert.False(t, ok) - - // cannot send to wrong ethAddr - ok, err = historyDBWithACC.CanSendToEthAddr(ethCommon.HexToAddress("0xE39fEc6224708f0772D2A74fd3f9055A90E00000"), acc.TokenID) - require.NoError(t, err) - assert.False(t, ok) - } } func TestTxs(t *testing.T) { diff --git a/db/kvdb/kvdb.go b/db/kvdb/kvdb.go index d65bfba0b..64bab1829 100644 --- a/db/kvdb/kvdb.go +++ b/db/kvdb/kvdb.go @@ -134,7 +134,6 @@ func NewKVDB(cfg Config) (*KVDB, error) { if err != nil { return nil, tracerr.Wrap(err) } - var last *Last if !cfg.NoLast { last = &Last{ @@ -435,7 +434,6 @@ func (k *KVDB) MakeCheckpoint() error { return tracerr.Wrap(err) } } - // execute Checkpoint if err := k.db.Pebble().Checkpoint(checkpointPath); err != nil { return tracerr.Wrap(err) diff --git a/db/l2db/apiqueries.go b/db/l2db/apiqueries.go index 66680022f..7d84c740f 100644 --- a/db/l2db/apiqueries.go +++ b/db/l2db/apiqueries.go @@ -2,12 +2,14 @@ package l2db import ( "fmt" + "math/big" ethCommon "github.com/ethereum/go-ethereum/common" "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db" "github.com/hermeznetwork/tracerr" "github.com/iden3/go-iden3-crypto/babyjub" + "github.com/jmoiron/sqlx" "github.com/russross/meddler" ) @@ -43,19 +45,19 @@ func (l2db *L2DB) GetAccountCreationAuthAPI(addr ethCommon.Address) (*AccountCre } // AddTxAPI inserts a tx to the pool -func (l2db *L2DB) AddTxAPI(tx *PoolL2TxWrite) error { +func (l2db *L2DB) AddTxAPI(tx *common.PoolL2Tx) error { cancel, err := l2db.apiConnCon.Acquire() defer cancel() if err != nil { return tracerr.Wrap(err) } defer l2db.apiConnCon.Release() - + // Check fee is in range row := l2db.dbRead.QueryRow(`SELECT ($1::NUMERIC * COALESCE(token.usd, 0) * fee_percentage($2::NUMERIC)) / (10.0 ^ token.decimals::NUMERIC) FROM token WHERE token.token_id = $3;`, - tx.AmountFloat, tx.Fee, tx.TokenID) + tx.Amount.String(), tx.Fee, tx.TokenID) var feeUSD float64 if err := row.Scan(&feeUSD); err != nil { return tracerr.Wrap(err) @@ -68,49 +70,92 @@ func (l2db *L2DB) AddTxAPI(tx *PoolL2TxWrite) error { return tracerr.Wrap(fmt.Errorf("tx.feeUSD (%v) > maxFeeUSD (%v)", feeUSD, l2db.maxFeeUSD)) } + // Add tx if pool is not full + return tracerr.Wrap( + l2db.addTxs([]common.PoolL2Tx{*tx}, true), + ) +} - // Prepare insert SQL query argument parameters - namesPart, err := meddler.Default.ColumnsQuoted(tx, false) - if err != nil { - return err +// AddAtomicTxsAPI inserts transactions into the pool +// if minFeeUSD <= total fee in USD <= maxFeeUSD. +// It's assumed that the given txs conform a single atomic group +// and AtomicGroupID will be set for all the txs awith value last AtomigGroupID in the DB +1 +func (l2db *L2DB) AddAtomicTxsAPI(txs []common.PoolL2Tx) error { + if len(txs) == 0 { + return nil } - valuesPart, err := meddler.Default.PlaceholdersString(tx, false) + // DB connection handling + cancel, err := l2db.apiConnCon.Acquire() + defer cancel() if err != nil { - return err + return tracerr.Wrap(err) } - values, err := meddler.Default.Values(tx, false) - if err != nil { - return err + defer l2db.apiConnCon.Release() + + // Calculate fee in token amount per each used token (don't include tokens with fee 0) + feeMap := make(map[common.TokenID]float64) + for _, tx := range txs { + f := big.NewFloat(0).SetInt(tx.Amount) + amountF, _ := f.Float64() + if _, ok := feeMap[tx.TokenID]; !ok && amountF > 0 { + feeMap[tx.TokenID] = tx.Fee.Percentage() * amountF + } else { + feeMap[tx.TokenID] += tx.Fee.Percentage() * amountF + } + } + tokenIDs := make([]common.TokenID, len(feeMap)) + pos := 0 + for id := range feeMap { + tokenIDs[pos] = id + pos++ } - q := fmt.Sprintf( - `INSERT INTO tx_pool (%s) - SELECT %s - WHERE (SELECT COUNT(*) FROM tx_pool WHERE state = $%v AND NOT external_delete) < $%v;`, - namesPart, valuesPart, - len(values)+1, len(values)+2) //nolint:gomnd - values = append(values, common.PoolL2TxStatePending, l2db.maxTxs) - res, err := l2db.dbWrite.Exec(q, values...) + // Get value in USD for the used tokens (value peer token without decimals) + query, args, err := sqlx.In( + `SELECT token_id, COALESCE(usd, 0) / (10.0 ^ token.decimals::NUMERIC) AS usd_no_decimals + FROM token WHERE token_id IN(?);`, + tokenIDs, + ) if err != nil { return tracerr.Wrap(err) } - rowsAffected, err := res.RowsAffected() - if err != nil { + query = l2db.dbRead.Rebind(query) + type tokenUSDValue struct { + TokenID common.TokenID `meddler:"token_id"` + USDPerToken float64 `meddler:"usd_no_decimals"` + } + USDValues := []*tokenUSDValue{} + if err := meddler.QueryAll(l2db.dbRead, &USDValues, query, args...); err != nil { return tracerr.Wrap(err) } - if rowsAffected == 0 { - return tracerr.Wrap(errPoolFull) + + // Calculate average fee per transaction + var avgFeeUSD float64 + for _, USDValue := range USDValues { + avgFeeUSD += feeMap[USDValue.TokenID] * USDValue.USDPerToken + } + avgFeeUSD = avgFeeUSD / float64(len(txs)) + // Check that the fee is in accepted range + if avgFeeUSD < l2db.minFeeUSD { + return tracerr.Wrap(fmt.Errorf("avgFeeUSD (%v) < minFeeUSD (%v)", + avgFeeUSD, l2db.minFeeUSD)) + } + if avgFeeUSD > l2db.maxFeeUSD { + return tracerr.Wrap(fmt.Errorf("avgFeeUSD (%v) > maxFeeUSD (%v)", + avgFeeUSD, l2db.maxFeeUSD)) } - return nil + + // Insert txs if the pool is not full + return tracerr.Wrap(l2db.addTxs(txs, true)) } // selectPoolTxAPI select part of queries to get PoolL2TxRead const selectPoolTxAPI = `SELECT tx_pool.item_id, tx_pool.tx_id, hez_idx(tx_pool.from_idx, token.symbol) AS from_idx, tx_pool.effective_from_eth_addr, tx_pool.effective_from_bjj, hez_idx(tx_pool.to_idx, token.symbol) AS to_idx, tx_pool.effective_to_eth_addr, tx_pool.effective_to_bjj, tx_pool.token_id, tx_pool.amount, tx_pool.fee, tx_pool.nonce, -tx_pool.state, tx_pool.info, tx_pool.signature, tx_pool.timestamp, tx_pool.batch_num, hez_idx(tx_pool.rq_from_idx, token.symbol) AS rq_from_idx, +tx_pool.state, tx_pool.info, tx_pool.error_code, tx_pool.error_type, tx_pool.signature, tx_pool.timestamp, tx_pool.batch_num, hez_idx(tx_pool.rq_from_idx, token.symbol) AS rq_from_idx, hez_idx(tx_pool.rq_to_idx, token.symbol) AS rq_to_idx, tx_pool.rq_to_eth_addr, tx_pool.rq_to_bjj, tx_pool.rq_token_id, tx_pool.rq_amount, -tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, +tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, tx_pool.max_num_batch, token.item_id AS token_item_id, token.eth_block_num, token.eth_addr, token.name, token.symbol, token.decimals, token.usd, token.usd_update FROM tx_pool INNER JOIN token ON tx_pool.token_id = token.token_id ` @@ -118,9 +163,9 @@ FROM tx_pool INNER JOIN token ON tx_pool.token_id = token.token_id ` const selectPoolTxsAPI = `SELECT tx_pool.item_id, tx_pool.tx_id, hez_idx(tx_pool.from_idx, token.symbol) AS from_idx, tx_pool.effective_from_eth_addr, tx_pool.effective_from_bjj, hez_idx(tx_pool.to_idx, token.symbol) AS to_idx, tx_pool.effective_to_eth_addr, tx_pool.effective_to_bjj, tx_pool.token_id, tx_pool.amount, tx_pool.fee, tx_pool.nonce, -tx_pool.state, tx_pool.info, tx_pool.signature, tx_pool.timestamp, tx_pool.batch_num, hez_idx(tx_pool.rq_from_idx, token.symbol) AS rq_from_idx, +tx_pool.state, tx_pool.info, tx_pool.error_code, tx_pool.error_type, tx_pool.signature, tx_pool.timestamp, tx_pool.batch_num, hez_idx(tx_pool.rq_from_idx, token.symbol) AS rq_from_idx, hez_idx(tx_pool.rq_to_idx, token.symbol) AS rq_to_idx, tx_pool.rq_to_eth_addr, tx_pool.rq_to_bjj, tx_pool.rq_token_id, tx_pool.rq_amount, -tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, +tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, tx_pool.max_num_batch, token.item_id AS token_item_id, token.eth_block_num, token.eth_addr, token.name, token.symbol, token.decimals, token.usd, token.usd_update, count(*) OVER() AS total_items FROM tx_pool INNER JOIN token ON tx_pool.token_id = token.token_id ` @@ -327,3 +372,27 @@ func (l2db *L2DB) GetPoolTxsAPI(request GetPoolTxsAPIRequest) ([]PoolTxAPI, uint } return txs, txs[0].TotalItems - uint64(len(txs)), tracerr.Wrap(err) } + +// GetPoolTxsByAtomicGroupIDAPI return Txs from the pool that belong to the given atomicGroupID +func (l2db *L2DB) GetPoolTxsByAtomicGroupIDAPI(atomicGroupID common.AtomicGroupID) ([]PoolTxAPI, error) { + cancel, err := l2db.apiConnCon.Acquire() + defer cancel() + if err != nil { + return nil, tracerr.Wrap(err) + } + defer l2db.apiConnCon.Release() + + txsPtrs := []*PoolTxAPI{} + if err := meddler.QueryAll( + l2db.dbRead, &txsPtrs, + selectPoolTxsAPI+" WHERE atomic_group_id = $1;", + atomicGroupID, + ); err != nil { + return nil, tracerr.Wrap(err) + } + txs := db.SlicePtrsToSlice(txsPtrs).([]PoolTxAPI) + if len(txs) == 0 { + return txs, nil + } + return txs, nil +} diff --git a/db/l2db/l2db.go b/db/l2db/l2db.go index b4bc8fc70..c3105ac7a 100644 --- a/db/l2db/l2db.go +++ b/db/l2db/l2db.go @@ -27,6 +27,7 @@ import ( "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db" "github.com/hermeznetwork/tracerr" + "github.com/iden3/go-iden3-crypto/babyjub" "github.com/jmoiron/sqlx" //nolint:errcheck // driver for postgres DB @@ -121,21 +122,30 @@ func (l2db *L2DB) UpdateTxsInfo(txs []common.PoolL2Tx, batchNum common.BatchNum) return nil } type txUpdate struct { - ID common.TxID `db:"id"` - Info string `db:"info"` + ID common.TxID `db:"id"` + Info string `db:"info"` + ErrorCode int `db:"error_code"` + ErrorType string `db:"error_type"` } txUpdates := make([]txUpdate, len(txs)) batchN := strconv.FormatInt(int64(batchNum), 10) for i := range txs { - txUpdates[i] = txUpdate{ID: txs[i].TxID, Info: "BatchNum: " + batchN + ". " + txs[i].Info} + txUpdates[i] = txUpdate{ + ID: txs[i].TxID, + Info: "BatchNum: " + batchN + ". " + txs[i].Info, + ErrorCode: txs[i].ErrorCode, + ErrorType: txs[i].ErrorType, + } } const query string = ` UPDATE tx_pool SET - info = tx_update.info + info = tx_update.info, + error_code = tx_update.error_code, + error_type = tx_update.error_type FROM (VALUES - (NULL::::BYTEA, NULL::::VARCHAR), - (:id, :info) - ) as tx_update (id, info) + (NULL::::BYTEA, NULL::::VARCHAR, NULL::::NUMERIC, NULL::::VARCHAR), + (:id, :info, :error_code, :error_type) + ) as tx_update (id, info, error_code, error_type) WHERE tx_pool.tx_id = tx_update.id; ` if len(txUpdates) > 0 { @@ -147,58 +157,143 @@ func (l2db *L2DB) UpdateTxsInfo(txs []common.PoolL2Tx, batchNum common.BatchNum) return nil } -// NewPoolL2TxWriteFromPoolL2Tx creates a new PoolL2TxWrite from a PoolL2Tx -func NewPoolL2TxWriteFromPoolL2Tx(tx *common.PoolL2Tx) *PoolL2TxWrite { - // transform tx from *common.PoolL2Tx to PoolL2TxWrite - insertTx := &PoolL2TxWrite{ - TxID: tx.TxID, - FromIdx: tx.FromIdx, - TokenID: tx.TokenID, - Amount: tx.Amount, - Fee: tx.Fee, - Nonce: tx.Nonce, - State: common.PoolL2TxStatePending, - Signature: tx.Signature, - RqAmount: tx.RqAmount, - Type: tx.Type, - } - if tx.ToIdx != 0 { - insertTx.ToIdx = &tx.ToIdx - } - nilAddr := ethCommon.BigToAddress(big.NewInt(0)) - if tx.ToEthAddr != nilAddr { - insertTx.ToEthAddr = &tx.ToEthAddr - } - if tx.RqFromIdx != 0 { - insertTx.RqFromIdx = &tx.RqFromIdx - } - if tx.RqToIdx != 0 { // if true, all Rq... fields must be different to nil - insertTx.RqToIdx = &tx.RqToIdx - insertTx.RqTokenID = &tx.RqTokenID - insertTx.RqFee = &tx.RqFee - insertTx.RqNonce = &tx.RqNonce - } - if tx.RqToEthAddr != nilAddr { - insertTx.RqToEthAddr = &tx.RqToEthAddr +// AddTxTest inserts a tx into the L2DB, without security checks. This is useful for test purposes, +func (l2db *L2DB) AddTxTest(tx *common.PoolL2Tx) error { + // Add tx without checking if pool is full + return tracerr.Wrap( + l2db.addTxs([]common.PoolL2Tx{*tx}, false), + ) +} + +// Insert PoolL2Tx transactions into the pool. If checkPoolIsFull is set to true the insert will +// fail if the pool is fool and errPoolFull will be returned +func (l2db *L2DB) addTxs(txs []common.PoolL2Tx, checkPoolIsFull bool) error { + // Set the columns that will be affected by the insert on the table + const queryInsertPart = `INSERT INTO tx_pool ( + tx_id, from_idx, to_idx, to_eth_addr, to_bjj, token_id, + amount, fee, nonce, state, info, signature, rq_from_idx, + rq_to_idx, rq_to_eth_addr, rq_to_bjj, rq_token_id, rq_amount, rq_fee, rq_nonce, + tx_type, amount_f, client_ip, rq_offset, atomic_group_id, max_num_batch + )` + var ( + queryVarsPart string + queryVars []interface{} + ) + for i := range txs { + // Format extra DB fields and nullables + var ( + toEthAddr *ethCommon.Address + toBJJ *babyjub.PublicKeyComp + // Info (always nil) + info *string + // Rq fields, nil unless tx.RqFromIdx != 0 + rqFromIdx *common.Idx + rqToIdx *common.Idx + rqToEthAddr *ethCommon.Address + rqToBJJ *babyjub.PublicKeyComp + rqTokenID *common.TokenID + rqAmount *string + rqFee *common.FeeSelector + rqNonce *common.Nonce + rqOffset *uint8 + atomicGroupID *common.AtomicGroupID + maxNumBatch *uint32 + ) + // AmountFloat + f := new(big.Float).SetInt((*big.Int)(txs[i].Amount)) + amountF, _ := f.Float64() + // ToEthAddr + if txs[i].ToEthAddr != common.EmptyAddr { + toEthAddr = &txs[i].ToEthAddr + } + // ToBJJ + if txs[i].ToBJJ != common.EmptyBJJComp { + toBJJ = &txs[i].ToBJJ + } + // MAxNumBatch + if txs[i].MaxNumBatch != 0 { + maxNumBatch = &txs[i].MaxNumBatch + } + // Rq fields + if txs[i].RqFromIdx != 0 { + // RqFromIdx + rqFromIdx = &txs[i].RqFromIdx + // RqToIdx + if txs[i].RqToIdx != 0 { + rqToIdx = &txs[i].RqToIdx + } + // RqToEthAddr + if txs[i].RqToEthAddr != common.EmptyAddr { + rqToEthAddr = &txs[i].RqToEthAddr + } + // RqToBJJ + if txs[i].RqToBJJ != common.EmptyBJJComp { + rqToBJJ = &txs[i].RqToBJJ + } + // RqTokenID + rqTokenID = &txs[i].RqTokenID + // RqAmount + if txs[i].RqAmount != nil { + rqAmountStr := txs[i].RqAmount.String() + rqAmount = &rqAmountStr + } + // RqFee + rqFee = &txs[i].RqFee + // RqNonce + rqNonce = &txs[i].RqNonce + // RqOffset + rqOffset = &txs[i].RqOffset + // AtomicGroupID + atomicGroupID = &txs[i].AtomicGroupID + } + // Each ? match one of the columns to be inserted as defined in queryInsertPart + const queryVarsPartPerTx = `(?::BYTEA, ?::BIGINT, ?::BIGINT, ?::BYTEA, ?::BYTEA, ?::INT, + ?::NUMERIC, ?::SMALLINT, ?::BIGINT, ?::CHAR(4), ?::VARCHAR, ?::BYTEA, ?::BIGINT, + ?::BIGINT, ?::BYTEA, ?::BYTEA, ?::INT, ?::NUMERIC, ?::SMALLINT, ?::BIGINT, + ?::VARCHAR(40), ?::NUMERIC, ?::VARCHAR, ?::SMALLINT, ?::BYTEA, ?::BIGINT)` + if i == 0 { + queryVarsPart += queryVarsPartPerTx + } else { + // Add coma before next tx values. + queryVarsPart += ", " + queryVarsPartPerTx + } + // Add values that will replace the ? + queryVars = append(queryVars, + txs[i].TxID, txs[i].FromIdx, txs[i].ToIdx, toEthAddr, toBJJ, txs[i].TokenID, + txs[i].Amount.String(), txs[i].Fee, txs[i].Nonce, txs[i].State, info, txs[i].Signature, rqFromIdx, + rqToIdx, rqToEthAddr, rqToBJJ, rqTokenID, rqAmount, rqFee, rqNonce, + txs[i].Type, amountF, txs[i].ClientIP, rqOffset, atomicGroupID, maxNumBatch, + ) } - if tx.ToBJJ != common.EmptyBJJComp { - insertTx.ToBJJ = &tx.ToBJJ + // Query begins with the insert statement + query := queryInsertPart + if checkPoolIsFull { + // This query creates a temporary table containing the values to insert + // that will only get selected if the pool is not full + query += " SELECT * FROM ( VALUES " + queryVarsPart + " ) as tmp " + // Temporary table with the values of the txs + " WHERE (SELECT COUNT (*) FROM tx_pool WHERE state = ? AND NOT external_delete) < ?;" // Check if the pool is full + queryVars = append(queryVars, common.PoolL2TxStatePending, l2db.maxTxs) + } else { + query += " VALUES " + queryVarsPart + " ON CONFLICT ON CONSTRAINT tx_id_unique DO UPDATE SET " + + "from_idx = excluded.from_idx, to_idx = excluded.to_idx, to_eth_addr = excluded.to_eth_addr, to_bjj = excluded.to_bjj," + + " token_id = excluded.token_id, amount = excluded.amount, fee = excluded.fee, nonce = excluded.nonce, state = excluded.state," + + "info = excluded.info, signature = excluded.signature, rq_from_idx = excluded.rq_from_idx, rq_to_idx = excluded.rq_to_idx, " + + "rq_to_bjj = excluded.rq_to_bjj, rq_token_id = excluded.rq_token_id, rq_amount = excluded.rq_amount, rq_fee = excluded.rq_fee, rq_nonce = excluded.rq_nonce," + + " tx_type = excluded.tx_type, amount_f = excluded.amount_f, client_ip = excluded.client_ip, " + + "rq_offset = excluded.rq_offset, max_num_batch = excluded.max_num_batch WHERE tx_pool.atomic_group_id IS NULL;" } - if tx.RqToBJJ != common.EmptyBJJComp { - insertTx.RqToBJJ = &tx.RqToBJJ + // Replace "?, ?, ... ?" ==> "$1, $2, ..., $(len(queryVars))" + query = l2db.dbRead.Rebind(query) + // Execute query + res, err := l2db.dbWrite.Exec(query, queryVars...) + if err == nil && checkPoolIsFull { + if rowsAffected, err := res.RowsAffected(); err != nil || rowsAffected == 0 { + // If the query didn't affect any row, and there is no error in the query + // it's safe to assume that the WERE clause wasn't true, and so the pool is full + return tracerr.Wrap(errPoolFull) + } } - f := new(big.Float).SetInt(tx.Amount) - amountF, _ := f.Float64() - insertTx.AmountFloat = amountF - return insertTx -} - -// AddTxTest inserts a tx into the L2DB. This is useful for test purposes, -// but in production txs will only be inserted through the API -func (l2db *L2DB) AddTxTest(tx *common.PoolL2Tx) error { - insertTx := NewPoolL2TxWriteFromPoolL2Tx(tx) - // insert tx - return tracerr.Wrap(meddler.Insert(l2db.dbWrite, "tx_pool", insertTx)) + return tracerr.Wrap(err) } // selectPoolTxCommon select part of queries to get common.PoolL2Tx @@ -206,7 +301,7 @@ const selectPoolTxCommon = `SELECT tx_pool.tx_id, from_idx, to_idx, tx_pool.to_ tx_pool.to_bjj, tx_pool.token_id, tx_pool.amount, tx_pool.fee, tx_pool.nonce, tx_pool.state, tx_pool.info, tx_pool.signature, tx_pool.timestamp, rq_from_idx, rq_to_idx, tx_pool.rq_to_eth_addr, tx_pool.rq_to_bjj, tx_pool.rq_token_id, tx_pool.rq_amount, -tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, +tx_pool.rq_fee, tx_pool.rq_nonce, tx_pool.tx_type, tx_pool.rq_offset, tx_pool.atomic_group_id, tx_pool.max_num_batch, (fee_percentage(tx_pool.fee::NUMERIC) * token.usd * tx_pool.amount_f) / (10.0 ^ token.decimals::NUMERIC) AS fee_usd, token.usd_update FROM tx_pool INNER JOIN token ON tx_pool.token_id = token.token_id ` @@ -226,7 +321,7 @@ func (l2db *L2DB) GetPendingTxs() ([]common.PoolL2Tx, error) { var txs []*common.PoolL2Tx err := meddler.QueryAll( l2db.dbRead, &txs, - selectPoolTxCommon+"WHERE state = $1 AND NOT external_delete;", + selectPoolTxCommon+"WHERE state = $1 AND NOT external_delete ORDER BY tx_pool.item_id ASC;", common.PoolL2TxStatePending, ) return db.SlicePtrsToSlice(txs).([]common.PoolL2Tx), tracerr.Wrap(err) @@ -378,6 +473,8 @@ func (l2db *L2DB) Purge(currentBatchNum common.BatchNum) (err error) { batch_num < $1 AND (state = $2 OR state = $3) ) OR ( state = $4 AND timestamp < $5 + ) OR ( + max_num_batch < $1 );`, currentBatchNum-l2db.safetyPeriod, common.PoolL2TxStateForged, diff --git a/db/l2db/l2db_test.go b/db/l2db/l2db_test.go index b81565d5b..f278d3c30 100644 --- a/db/l2db/l2db_test.go +++ b/db/l2db/l2db_test.go @@ -3,6 +3,7 @@ package l2db import ( "database/sql" "fmt" + "math/big" "os" "testing" "time" @@ -172,10 +173,18 @@ func TestAddTxTest(t *testing.T) { assert.Equal(t, "UTC", nameZone) assert.Equal(t, 0, offset) } + + // test, that we can update already existing tx tx := &poolL2Txs[1] + fetchedTx, err := l2DB.GetTx(tx.TxID) + require.NoError(t, err) + assert.Equal(t, fetchedTx.TokenID, common.TokenID(2)) + tx.TokenID = common.TokenID(1) err = l2DBWithACC.AddTxTest(tx) - require.Error(t, err) - assert.Regexp(t, "duplicate key value", err.Error()) + require.NoError(t, err) + fetchedTx, err = l2DB.GetTx(tx.TxID) + require.NoError(t, err) + assert.Equal(t, fetchedTx.TokenID, common.TokenID(1)) } func TestAddTxAPI(t *testing.T) { @@ -189,14 +198,10 @@ func TestAddTxAPI(t *testing.T) { l2DBWithACC.maxTxs = 5 poolL2Txs, err := generatePoolL2Txs() - txs := make([]*PoolL2TxWrite, len(poolL2Txs)) - for i := range poolL2Txs { - txs[i] = NewPoolL2TxWriteFromPoolL2Tx(&poolL2Txs[i]) - } require.NoError(t, err) require.GreaterOrEqual(t, len(poolL2Txs), 8) - for i := range txs[:5] { - err := l2DBWithACC.AddTxAPI(txs[i]) + for i := range poolL2Txs[:5] { + err := l2DBWithACC.AddTxAPI(&poolL2Txs[i]) require.NoError(t, err) fetchedTx, err := l2DB.GetTx(poolL2Txs[i].TxID) require.NoError(t, err) @@ -205,7 +210,7 @@ func TestAddTxAPI(t *testing.T) { assert.Equal(t, "UTC", nameZone) assert.Equal(t, 0, offset) } - err = l2DBWithACC.AddTxAPI(txs[5]) + err = l2DBWithACC.AddTxAPI(&poolL2Txs[5]) assert.Equal(t, errPoolFull, tracerr.Unwrap(err)) // reset maxTxs to original value l2DBWithACC.maxTxs = oldMaxTxs @@ -213,13 +218,13 @@ func TestAddTxAPI(t *testing.T) { // set minFeeUSD to a high value than the tx feeUSD to test the error // of inserting a tx with lower than min fee oldMinFeeUSD := l2DBWithACC.minFeeUSD - tx := txs[5] + tx := poolL2Txs[5] feeAmount, err := common.CalcFeeAmount(tx.Amount, tx.Fee) require.NoError(t, err) feeAmountUSD := common.TokensToUSD(feeAmount, decimals, tokenValue) // set minFeeUSD higher than the tx fee to trigger the error l2DBWithACC.minFeeUSD = feeAmountUSD + 1 - err = l2DBWithACC.AddTxAPI(tx) + err = l2DBWithACC.AddTxAPI(&tx) require.Error(t, err) assert.Regexp(t, "tx.feeUSD (.*) < minFeeUSD (.*)", err.Error()) // reset minFeeUSD to original value @@ -293,6 +298,18 @@ func TestGetPending(t *testing.T) { poolL2Txs, err := generatePoolL2Txs() require.NoError(t, err) var pendingTxs []*common.PoolL2Tx + // Add case for fields that have been added after the original schema + poolL2Txs[0].AtomicGroupID = common.AtomicGroupID([common.AtomicGroupIDLen]byte{9}) + poolL2Txs[0].RqNonce = 1 + poolL2Txs[0].RqTokenID = 1 + poolL2Txs[0].RqFromIdx = 678 + poolL2Txs[0].RqToIdx = 679 + poolL2Txs[0].RqAmount = big.NewInt(99999) + poolL2Txs[0].RqFee = 200 + poolL2Txs[0].RqOffset = 3 + poolL2Txs[0].RqToEthAddr = ethCommon.BigToAddress(big.NewInt(11111111)) + poolL2Txs[0].MaxNumBatch = 123456 + for i := range poolL2Txs { err := l2DB.AddTxTest(&poolL2Txs[i]) require.NoError(t, err) @@ -834,11 +851,7 @@ func TestAddGet(t *testing.T) { for i := 0; i < len(txs); i++ { dbTx, err := l2DB.GetTx(txs[i].TxID) require.NoError(t, err) - // Ignore Timestamp, AbsoluteFee, AbsoluteFeeUpdate - txs[i].Timestamp = dbTx.Timestamp - txs[i].AbsoluteFee = dbTx.AbsoluteFee - txs[i].AbsoluteFeeUpdate = dbTx.AbsoluteFeeUpdate - assert.Equal(t, txs[i], *dbTx) + assertTx(t, &txs[i], dbTx) } } diff --git a/db/l2db/views.go b/db/l2db/views.go index 15e37f14d..d18060537 100644 --- a/db/l2db/views.go +++ b/db/l2db/views.go @@ -2,7 +2,6 @@ package l2db import ( "encoding/json" - "math/big" "time" ethCommon "github.com/ethereum/go-ethereum/common" @@ -11,32 +10,6 @@ import ( "github.com/iden3/go-iden3-crypto/babyjub" ) -// PoolL2TxWrite holds the necessary data to perform inserts in tx_pool -type PoolL2TxWrite struct { - TxID common.TxID `meddler:"tx_id"` - FromIdx common.Idx `meddler:"from_idx"` - ToIdx *common.Idx `meddler:"to_idx"` - ToEthAddr *ethCommon.Address `meddler:"to_eth_addr"` - ToBJJ *babyjub.PublicKeyComp `meddler:"to_bjj"` - TokenID common.TokenID `meddler:"token_id"` - Amount *big.Int `meddler:"amount,bigint"` - AmountFloat float64 `meddler:"amount_f"` - Fee common.FeeSelector `meddler:"fee"` - Nonce common.Nonce `meddler:"nonce"` - State common.PoolL2TxState `meddler:"state"` - Signature babyjub.SignatureComp `meddler:"signature"` - RqFromIdx *common.Idx `meddler:"rq_from_idx"` - RqToIdx *common.Idx `meddler:"rq_to_idx"` - RqToEthAddr *ethCommon.Address `meddler:"rq_to_eth_addr"` - RqToBJJ *babyjub.PublicKeyComp `meddler:"rq_to_bjj"` - RqTokenID *common.TokenID `meddler:"rq_token_id"` - RqAmount *big.Int `meddler:"rq_amount,bigintnull"` - RqFee *common.FeeSelector `meddler:"rq_fee"` - RqNonce *common.Nonce `meddler:"rq_nonce"` - Type common.TxType `meddler:"tx_type"` - ClientIP string `meddler:"client_ip"` -} - // PoolTxAPI represents a L2 Tx pool with extra metadata used by the API type PoolTxAPI struct { ItemID uint64 `meddler:"item_id"` @@ -51,7 +24,10 @@ type PoolTxAPI struct { Fee common.FeeSelector `meddler:"fee"` Nonce common.Nonce `meddler:"nonce"` State common.PoolL2TxState `meddler:"state"` + MaxNumBatch uint32 `meddler:"max_num_batch,zeroisnull"` Info *string `meddler:"info"` + ErrorCode *int `meddler:"error_code"` + ErrorType *string `meddler:"error_type"` Signature babyjub.SignatureComp `meddler:"signature"` RqFromIdx *apitypes.HezIdx `meddler:"rq_from_idx"` RqToIdx *apitypes.HezIdx `meddler:"rq_to_idx"` @@ -94,7 +70,10 @@ func (tx PoolTxAPI) MarshalJSON() ([]byte, error) { "fee": tx.Fee, "nonce": tx.Nonce, "state": tx.State, + "maxNumBatch": tx.MaxNumBatch, "info": tx.Info, + "errorCode": tx.ErrorCode, + "errorType": tx.ErrorType, "signature": tx.Signature, "timestamp": tx.Timestamp, "requestFromAccountIndex": tx.RqFromIdx, diff --git a/db/migrations/0005.sql b/db/migrations/0005.sql index 1659b8f57..f913e652e 100644 --- a/db/migrations/0005.sql +++ b/db/migrations/0005.sql @@ -2,4 +2,4 @@ ALTER TABLE token ALTER COLUMN name TYPE varchar; -- +migrate Down -ALTER TABLE token ALTER COLUMN name TYPE varchar(20) USING SUBSTR(name, 1, 20); \ No newline at end of file +ALTER TABLE token ALTER COLUMN name TYPE varchar(20) USING SUBSTR(name, 1, 20); diff --git a/db/migrations/0006.sql b/db/migrations/0006.sql new file mode 100644 index 000000000..429c3ba91 --- /dev/null +++ b/db/migrations/0006.sql @@ -0,0 +1,9 @@ +-- +migrate Up +ALTER TABLE tx_pool +ADD COLUMN rq_offset SMALLINT DEFAULT NULL, +ADD COLUMN atomic_group_id BYTEA DEFAULT NULL; + +-- +migrate Down +ALTER TABLE tx_pool +DROP COLUMN rq_offset, +DROP COLUMN atomic_group_id; \ No newline at end of file diff --git a/db/migrations/0006_test.go b/db/migrations/0006_test.go new file mode 100644 index 000000000..ee10ce239 --- /dev/null +++ b/db/migrations/0006_test.go @@ -0,0 +1,199 @@ +package migrations_test + +import ( + "testing" + + "github.com/jmoiron/sqlx" + "github.com/stretchr/testify/assert" +) + +// This migration adds the column `rq_offset` and `atomic_group_id` on `tx_pool` + +type migrationTest0006 struct{} + +func (m migrationTest0006) InsertData(db *sqlx.DB) error { + // insert block to respect the FKey of token + const queryInsertBlock = `INSERT INTO block ( + eth_block_num,"timestamp",hash + ) VALUES ( + 4417296,'2021-03-10 16:44:06.000',decode('C4D46677F3B2511D96389521C2BDFFE91127DE214423FF14899A6177631D2105','hex') + );` + // insert token to respect the FKey of tx_pool + const queryInsertToken = `INSERT INTO "token" ( + token_id,eth_block_num,eth_addr,"name",symbol,decimals,usd,usd_update + ) VALUES ( + 2,4417296,decode('1B36A4DED4DF40248C0E0E52CEA5EDC9A298B721','hex'),'Dai Stablecoin','DAI',18,1.01,'2021-04-17 20:21:16.870' + );` + // insert batch to respect the FKey of account + const queryInsertBatch = `INSERT INTO batch ( + batch_num, + eth_block_num, + forger_addr, + fees_collected, + fee_idxs_coordinator, + state_root, + num_accounts, + last_idx, + exit_root, + forge_l1_txs_num, + slot_num, + total_fees_usd + ) VALUES ( + 6758, + 4417296, + decode('459264CC7D2BF350AFDDA828C273E81367729C1F', 'hex'), + decode('7B2230223A34383337383531313632323134343030307D0A', 'hex'), + decode('5B3236335D0A', 'hex'), + 12898140512818699175738765060248919016800434587665040485377676113605873428098, + 256, + 1044, + 0, + NULL, + 717, + 115.047487133272 + );` + // isert account to set effective_from_eth_addr, effective_from_bjj through trigger + const queryInsertAccount = `INSERT INTO account ( + idx,token_id,batch_num,bjj,eth_addr + ) VALUES ( + 789,2,6758,decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A','hex'),decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F','hex') + );` + // insert a row in tx_pool with all the fields setted + const queryInsertTxPool = `INSERT INTO tx_pool ( + tx_id, from_idx, effective_from_eth_addr, effective_from_bjj, to_idx, to_eth_addr, to_bjj, effective_to_eth_addr, effective_to_bjj, + token_id, amount, amount_f, fee, nonce, state, info, signature, "timestamp", batch_num, + rq_from_idx,rq_to_idx,rq_to_eth_addr,rq_to_bjj,rq_token_id,rq_amount,rq_fee,rq_nonce,tx_type,client_ip,external_delete + ) VALUES ( + decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex'), + 789, + decode('FF', 'hex'), -- Note that this field will be replaced by trigger with account table values + decode('FF', 'hex'), -- Note that this field will be replaced by trigger with account table values + 1, + decode('1224456678907543564567567567567657567567', 'hex'), + decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex'), + decode('1224456678907543564567567567567657567567', 'hex'), + decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex'), + 2, + 5, + 5, + 227, + 3, + 'pend', + 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions', + decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex'), + '2021-05-06 15:02:47.616', + 32, + 765, + 567, + decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex'), + decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex'), + 5, + 345345345, + 33, + 4, + 'Exit', + '93.176.174.84', + true + );` + _, err := db.Exec(queryInsertBlock + + queryInsertToken + + queryInsertBatch + + queryInsertAccount + + queryInsertTxPool, + ) + return err +} + +func (m migrationTest0006) RunAssertsAfterMigrationUp(t *testing.T, db *sqlx.DB) { + // check that the tx_pool inserted in previous step is persisted + // with same content, except item_id is added + const queryGetTxPool = `SELECT COUNT(*) FROM tx_pool WHERE + tx_id = decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex') AND + from_idx = 789 AND + effective_from_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + effective_from_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + to_idx = 1 AND + to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + effective_to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + effective_to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + token_id = 2 AND + amount = 5 AND + amount_f = 5 AND + fee = 227 AND + nonce = 3 AND + state = 'pend' AND + info = 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions' AND + signature = decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex') AND + "timestamp" = '2021-05-06 15:02:47.616' AND + batch_num = 32 AND + rq_from_idx = 765 AND + rq_to_idx = 567 AND + rq_to_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + rq_to_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + rq_token_id = 5 AND + rq_amount = 345345345 AND + rq_fee = 33 AND + rq_nonce = 4 AND + tx_type = 'Exit' AND + client_ip = '93.176.174.84' AND + external_delete = true AND + item_id = 1 AND -- Note that item_id is an autoincremental column, so this value is setted automatically + rq_offset IS NULL AND + atomic_group_id IS NULL;` + row := db.QueryRow(queryGetTxPool) + var result int + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) +} + +func (m migrationTest0006) RunAssertsAfterMigrationDown(t *testing.T, db *sqlx.DB) { + // check that the tx_pool inserted in previous step is persisted with same content + const queryGetTxPool = `SELECT COUNT(*) FROM tx_pool WHERE + tx_id = decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex') AND + from_idx = 789 AND + effective_from_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + effective_from_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + to_idx = 1 AND + to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + effective_to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + effective_to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + token_id = 2 AND + amount = 5 AND + amount_f = 5 AND + fee = 227 AND + nonce = 3 AND + state = 'pend' AND + info = 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions' AND + signature = decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex') AND + "timestamp" = '2021-05-06 15:02:47.616' AND + batch_num = 32 AND + rq_from_idx = 765 AND + rq_to_idx = 567 AND + rq_to_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + rq_to_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + rq_token_id = 5 AND + rq_amount = 345345345 AND + rq_fee = 33 AND + rq_nonce = 4 AND + tx_type = 'Exit' AND + client_ip = '93.176.174.84' AND + item_id = 1 AND + external_delete = true;` + row := db.QueryRow(queryGetTxPool) + var result int + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) + // check that atomic_group_id amd rq_offset colum doesn't exist anymore + const queryCheckRqOffset = `SELECT COUNT(*) FROM tx_pool WHERE rq_offset IS NULL;` + row = db.QueryRow(queryCheckRqOffset) + assert.Equal(t, `pq: column "rq_offset" does not exist`, row.Scan(&result).Error()) + const queryCheckAtomicGroupID = `SELECT COUNT(*) FROM tx_pool WHERE atomic_group_id IS NULL;` + row = db.QueryRow(queryCheckAtomicGroupID) + assert.Equal(t, `pq: column "atomic_group_id" does not exist`, row.Scan(&result).Error()) +} + +func TestMigration0006(t *testing.T) { + runMigrationTest(t, 6, migrationTest0006{}) +} diff --git a/db/migrations/0007.sql b/db/migrations/0007.sql new file mode 100644 index 000000000..e80d0c91c --- /dev/null +++ b/db/migrations/0007.sql @@ -0,0 +1,5 @@ +-- +migrate Up +ALTER TABLE tx_pool ADD COLUMN max_num_batch BIGINT DEFAULT NULL; + +-- +migrate Down +ALTER TABLE tx_pool DROP COLUMN max_num_batch; \ No newline at end of file diff --git a/db/migrations/0007_test.go b/db/migrations/0007_test.go new file mode 100644 index 000000000..0f323b987 --- /dev/null +++ b/db/migrations/0007_test.go @@ -0,0 +1,201 @@ +package migrations_test + +import ( + "testing" + + "github.com/jmoiron/sqlx" + "github.com/stretchr/testify/assert" +) + +// This migration adds the column `rq_offset` and `atomic_group_id` on `tx_pool` + +type migrationTest0007 struct{} + +func (m migrationTest0007) InsertData(db *sqlx.DB) error { + // insert block to respect the FKey of token + const queryInsertBlock = `INSERT INTO block ( + eth_block_num,"timestamp",hash + ) VALUES ( + 4417296,'2021-03-10 16:44:06.000',decode('C4D46677F3B2511D96389521C2BDFFE91127DE214423FF14899A6177631D2105','hex') + );` + // insert token to respect the FKey of tx_pool + const queryInsertToken = `INSERT INTO "token" ( + token_id,eth_block_num,eth_addr,"name",symbol,decimals,usd,usd_update + ) VALUES ( + 2,4417296,decode('1B36A4DED4DF40248C0E0E52CEA5EDC9A298B721','hex'),'Dai Stablecoin','DAI',18,1.01,'2021-04-17 20:21:16.870' + );` + // insert batch to respect the FKey of account + const queryInsertBatch = `INSERT INTO batch ( + batch_num, + eth_block_num, + forger_addr, + fees_collected, + fee_idxs_coordinator, + state_root, + num_accounts, + last_idx, + exit_root, + forge_l1_txs_num, + slot_num, + total_fees_usd + ) VALUES ( + 6758, + 4417296, + decode('459264CC7D2BF350AFDDA828C273E81367729C1F', 'hex'), + decode('7B2230223A34383337383531313632323134343030307D0A', 'hex'), + decode('5B3236335D0A', 'hex'), + 12898140512818699175738765060248919016800434587665040485377676113605873428098, + 256, + 1044, + 0, + NULL, + 717, + 115.047487133272 + );` + // isert account to set effective_from_eth_addr, effective_from_bjj through trigger + const queryInsertAccount = `INSERT INTO account ( + idx,token_id,batch_num,bjj,eth_addr + ) VALUES ( + 789,2,6758,decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A','hex'),decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F','hex') + );` + // insert a row in tx_pool with all the fields setted + const queryInsertTxPool = `INSERT INTO tx_pool ( + tx_id, from_idx, effective_from_eth_addr, effective_from_bjj, to_idx, to_eth_addr, to_bjj, effective_to_eth_addr, effective_to_bjj, + token_id, amount, amount_f, fee, nonce, state, info, signature, "timestamp", batch_num, + rq_from_idx,rq_to_idx,rq_to_eth_addr,rq_to_bjj,rq_token_id,rq_amount,rq_fee,rq_nonce,tx_type,client_ip,external_delete,rq_offset,atomic_group_id + ) VALUES ( + decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex'), + 789, + decode('FF', 'hex'), -- Note that this field will be replaced by trigger with account table values + decode('FF', 'hex'), -- Note that this field will be replaced by trigger with account table values + 1, + decode('1224456678907543564567567567567657567567', 'hex'), + decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex'), + decode('1224456678907543564567567567567657567567', 'hex'), + decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex'), + 2, + 5, + 5, + 227, + 3, + 'pend', + 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions', + decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex'), + '2021-05-06 15:02:47.616', + 32, + 765, + 567, + decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex'), + decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex'), + 5, + 345345345, + 33, + 4, + 'Exit', + '93.176.174.84', + true, + 1, + decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') + );` + _, err := db.Exec(queryInsertBlock + + queryInsertToken + + queryInsertBatch + + queryInsertAccount + + queryInsertTxPool, + ) + return err +} + +func (m migrationTest0007) RunAssertsAfterMigrationUp(t *testing.T, db *sqlx.DB) { + // check that the tx_pool inserted in previous step is persisted + // with same content, except item_id is added + const queryGetTxPool = `SELECT COUNT(*) FROM tx_pool WHERE + tx_id = decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex') AND + from_idx = 789 AND + effective_from_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + effective_from_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + to_idx = 1 AND + to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + effective_to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + effective_to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + token_id = 2 AND + amount = 5 AND + amount_f = 5 AND + fee = 227 AND + nonce = 3 AND + state = 'pend' AND + info = 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions' AND + signature = decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex') AND + "timestamp" = '2021-05-06 15:02:47.616' AND + batch_num = 32 AND + rq_from_idx = 765 AND + rq_to_idx = 567 AND + rq_to_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + rq_to_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + rq_token_id = 5 AND + rq_amount = 345345345 AND + rq_fee = 33 AND + rq_nonce = 4 AND + tx_type = 'Exit' AND + client_ip = '93.176.174.84' AND + external_delete = true AND + item_id = 1 AND -- Note that item_id is an autoincremental column, so this value is setted automaticallyAND + rq_offset = 1 AND + atomic_group_id = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + max_num_batch IS NULL;` + row := db.QueryRow(queryGetTxPool) + var result int + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) +} + +func (m migrationTest0007) RunAssertsAfterMigrationDown(t *testing.T, db *sqlx.DB) { + // check that the tx_pool inserted in previous step is persisted with same content + const queryGetTxPool = `SELECT COUNT(*) FROM tx_pool WHERE + tx_id = decode('023A0D72BEB1095C28A7130D896F484CC9D465C1C95F1617C0A7B2094E3E1F11FF', 'hex') AND + from_idx = 789 AND + effective_from_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + effective_from_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + to_idx = 1 AND + to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + effective_to_eth_addr = decode('1224456678907543564567567567567657567567', 'hex') AND + effective_to_bjj = decode('1224456678907543564567567567567657567567000000000000000000000000', 'hex') AND + token_id = 2 AND + amount = 5 AND + amount_f = 5 AND + fee = 227 AND + nonce = 3 AND + state = 'pend' AND + info = 'Exits with amount 0 have no sense, not accepting to prevent unintended transactions' AND + signature = decode('9C6A159C57D7FC58E3E5D3510FBC64EAC9C0D56A1B3144D94D6BBA4C23B9402CEE57D0CFF4A3BE135CBD2393AB8FD2A1840A62281B1721801DBF708D27F1DF00', 'hex') AND + "timestamp" = '2021-05-06 15:02:47.616' AND + batch_num = 32 AND + rq_from_idx = 765 AND + rq_to_idx = 567 AND + rq_to_eth_addr = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex') AND + rq_to_bjj = decode('FDDACE21457376B0952CCD19CE66B854FDD7C6E45905B0A0A75747C87D41719A', 'hex') AND + rq_token_id = 5 AND + rq_amount = 345345345 AND + rq_fee = 33 AND + rq_nonce = 4 AND + tx_type = 'Exit' AND + client_ip = '93.176.174.84' AND + item_id = 1 AND + external_delete = true AND + rq_offset = 1 AND + atomic_group_id = decode('A631BE6995643E6085330A31B9E1AF48DD5D6B7F', 'hex');` + row := db.QueryRow(queryGetTxPool) + var result int + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) + // check that max_num_batch colum doesn't exist anymore + const queryCheckRqOffset = `SELECT COUNT(*) FROM tx_pool WHERE max_num_batch IS NULL;` + row = db.QueryRow(queryCheckRqOffset) + assert.Equal(t, `pq: column "max_num_batch" does not exist`, row.Scan(&result).Error()) +} + +func TestMigration0007(t *testing.T) { + runMigrationTest(t, 7, migrationTest0007{}) +} diff --git a/db/migrations/0008.sql b/db/migrations/0008.sql new file mode 100644 index 000000000..b73e7320b --- /dev/null +++ b/db/migrations/0008.sql @@ -0,0 +1,9 @@ +-- +migrate Up +ALTER TABLE tx_pool +ADD COLUMN error_code NUMERIC, +ADD COLUMN error_type VARCHAR; + +-- +migrate Down +ALTER TABLE tx_pool +DROP COLUMN error_code, +DROP COLUMN error_type; diff --git a/db/migrations/0008_test.go b/db/migrations/0008_test.go new file mode 100644 index 000000000..8490d1449 --- /dev/null +++ b/db/migrations/0008_test.go @@ -0,0 +1,214 @@ +package migrations_test + +import ( + "testing" + + "github.com/jmoiron/sqlx" + "github.com/stretchr/testify/assert" +) + +// This migration creates the fiat table + +type migrationTest0008 struct{} + +func (m migrationTest0008) InsertData(db *sqlx.DB) error { + return nil +} + +func (m migrationTest0008) RunAssertsAfterMigrationUp(t *testing.T, db *sqlx.DB) { + //Insert data in the tx_pool table + const queryInsert = `INSERT INTO tx_pool (tx_id, + from_idx, + effective_from_eth_addr, + effective_from_bjj, + to_idx, + to_eth_addr, + to_bjj, + effective_to_eth_addr, + effective_to_bjj, + token_id, + amount, + amount_f, + fee, + nonce, + state, + info, + signature, + "timestamp", + batch_num, + rq_from_idx, + rq_to_idx, + rq_to_eth_addr, + rq_to_bjj, + rq_token_id, + rq_amount, + rq_fee, + rq_nonce, + tx_type, + client_ip, + external_delete, + item_id, + error_code, + error_type) VALUES(decode('03A193BC53932580F2EF91B5DA038AF611D9F1D896D518CDD65B1D766CBD835E30','hex'), + 3142, + decode('380ED8BD696C78395FB1961BDA42739D2F5242A1','hex'), + decode('CA780AF6B4C6164157DF737CE3E1E0A29EC9523F5B2CB4ADC26560379BFD5080','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + 0, + 34565432000000, + 34565432000000, + 20, + 28, + 'fged', + NULL, + decode('226B72179B58EC2D2106EAF40D828DF31F1FA92F2ED7DAC263E04259BDCE3085C803B7EC7F57E44E0C63234E52BFD28404332204B2F53A4589CB0B83531B0B05','hex'), + '2021-07-16 10:19:15.671', + 6164, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + 'TransferToEthAddr', + '95.127.153.55', + false, + 28494, + 15, + 'ErrToIdxNotFound'); + ` + _, err := db.Exec(queryInsert) + assert.NoError(t, err) + const queryGetNumberItems = `select count(*) from tx_pool;` + row := db.QueryRow(queryGetNumberItems) + var result int + assert.NoError(t, row.Scan(&result)) + assert.Equal(t, 1, result) +} + +func (m migrationTest0008) RunAssertsAfterMigrationDown(t *testing.T, db *sqlx.DB) { + // check that the fiat table is not created and I can't insert data + const queryInsert = `INSERT INTO tx_pool (tx_id, + from_idx, + effective_from_eth_addr, + effective_from_bjj, + to_idx, + to_eth_addr, + to_bjj, + effective_to_eth_addr, + effective_to_bjj, + token_id, + amount, + amount_f, + fee, + nonce, + state, + info, + signature, + "timestamp", + batch_num, + rq_from_idx, + rq_to_idx, + rq_to_eth_addr, + rq_to_bjj, + rq_token_id, + rq_amount, + rq_fee, + rq_nonce, + tx_type, + client_ip, + external_delete, + item_id, + error_code, + error_type) VALUES(decode('02A194BC53932580F2EF91B5DA038AF611D9F1D896D518CDD65B1D766CBD835E31','hex'), + 3142, + decode('380ED8BD696C78395FB1961BDA42739D2F5242A1','hex'), + decode('CA780AF6B4C6164157DF737CE3E1E0A29EC9523F5B2CB4ADC26560379BFD5080','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + 0, + 34565432000000, + 34565432000000, + 20, + 28, + 'fged', + NULL, + decode('226B72179B58EC2D2106EAF40D828DF31F1FA92F2ED7DAC263E04259BDCE3085C803B7EC7F57E44E0C63234E52BFD28404332204B2F53A4589CB0B83531B0B05','hex'), + '2021-07-16 10:19:15.671', + 6164, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + 'TransferToEthAddr', + '95.127.153.55', + false, + 28495, + 15, + 'ErrToIdxNotFound'); + ` + _, err := db.Exec(queryInsert) + if assert.Error(t, err) { + assert.Equal(t, `pq: column "error_code" of relation "tx_pool" does not exist`, err.Error()) + } + const query2Insert = `INSERT INTO tx_pool (tx_id, + from_idx, + effective_from_eth_addr, + effective_from_bjj, + to_idx, + to_eth_addr, + to_bjj, + effective_to_eth_addr, + effective_to_bjj, + token_id, + amount, + amount_f, + fee, + nonce, + state, + info, + signature, + "timestamp", + batch_num, + rq_from_idx, + rq_to_idx, + rq_to_eth_addr, + rq_to_bjj, + rq_token_id, + rq_amount, + rq_fee, + rq_nonce, + tx_type, + client_ip, + external_delete, + item_id) VALUES(decode('02A193BC63932580F2EF91B5DA038AF611D9F1D896D518CDD65B1D766CBD835E32','hex'), + 3142, + decode('380ED8BD696C78395FB1961BDA42739D2F5242A1','hex'), + decode('CA780AF6B4C6164157DF737CE3E1E0A29EC9523F5B2CB4ADC26560379BFD5080','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + decode('15868E0C2DFC14A47FFC7360A93ADDC994386B11','hex'), + NULL, + 0, + 34565432000000, + 34565432000000, + 20, + 28, + 'fged', + NULL, + decode('226B72179B58EC2D2106EAF40D828DF31F1FA92F2ED7DAC263E04259BDCE3085C803B7EC7F57E44E0C63234E52BFD28404332204B2F53A4589CB0B83531B0B05','hex'), + '2021-07-16 10:19:15.671', + 6164, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + 'TransferToEthAddr', + '95.127.153.55', + false, + 28496); + ` + _, err = db.Exec(query2Insert) + assert.NoError(t, err) +} + +func TestMigration0008(t *testing.T) { + runMigrationTest(t, 8, migrationTest0008{}) +} diff --git a/db/statedb/statedb.go b/db/statedb/statedb.go index b11e74a12..0d1193db4 100644 --- a/db/statedb/statedb.go +++ b/db/statedb/statedb.go @@ -149,7 +149,6 @@ func NewStateDB(cfg Config) (*StateDB, error) { return nil, tracerr.Wrap( fmt.Errorf("invalid StateDB parameters: StateDB type==TypeStateDB can not have nLevels!=0")) } - return &StateDB{ cfg: cfg, db: kv, diff --git a/eth/auction.go b/eth/auction.go index 470a2faa4..7d1ec602c 100644 --- a/eth/auction.go +++ b/eth/auction.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/hermeznetwork/hermez-node/common" - HermezAuctionProtocol "github.com/hermeznetwork/hermez-node/eth/contracts/auction" + auction "github.com/hermeznetwork/hermez-node/eth/contracts/auction" "github.com/hermeznetwork/hermez-node/log" "github.com/hermeznetwork/tracerr" ) @@ -271,7 +271,7 @@ type AuctionClient struct { client *EthereumClient chainID *big.Int address ethCommon.Address - auction *HermezAuctionProtocol.HermezAuctionProtocol + auction *auction.Auction token *TokenClient contractAbi abi.ABI opts *bind.CallOpts @@ -280,11 +280,11 @@ type AuctionClient struct { // NewAuctionClient creates a new AuctionClient. `tokenAddress` is the address of the HEZ tokens. func NewAuctionClient(client *EthereumClient, address, tokenAddress ethCommon.Address) (*AuctionClient, error) { contractAbi, err := - abi.JSON(strings.NewReader(string(HermezAuctionProtocol.HermezAuctionProtocolABI))) + abi.JSON(strings.NewReader(string(auction.AuctionABI))) if err != nil { return nil, tracerr.Wrap(err) } - auction, err := HermezAuctionProtocol.NewHermezAuctionProtocol(address, client.Client()) + auction, err := auction.NewAuction(address, client.Client()) if err != nil { return nil, tracerr.Wrap(err) } diff --git a/eth/contracts/abi/HEZ.json b/eth/contracts/abi/HEZ.json new file mode 100644 index 000000000..86a0d6635 --- /dev/null +++ b/eth/contracts/abi/HEZ.json @@ -0,0 +1,510 @@ +{ + "contractName": "HEZ", + "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "initialHolder", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "authorizer", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "nonce", + "type": "bytes32" + } + ], + "name": "AuthorizationUsed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "EIP712DOMAIN_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NAME_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TRANSFER_WITH_AUTHORIZATION_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "authorizationState", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "initialBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validAfter", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "validBefore", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "nonce", + "type": "bytes32" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "transferWithAuthorization", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x60806040523480156200001157600080fd5b506040516200147038038062001470833981810160405260208110156200003757600080fd5b505162000050816a52b7d2dcc80cd2e400000062000057565b50620001c2565b6200007381600054620000ff60201b62000b2a1790919060201c565b60009081556001600160a01b038316815260016020908152604090912054620000a791839062000b2a620000ff821b17901c565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6040805180820190915260118152704d4154483a4144445f4f564552464c4f5760781b60208201528183019083821015620001bb5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156200017f57818101518382015260200162000165565b50505050905090810190601f168015620001ad5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5092915050565b61129e80620001d26000396000f3fe608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e1461041d578063e3ee160e14610458578063e94a0102146104c457610177565b8063a9059cbb1461037c578063c473af33146103b5578063d505accf146103bd57610177565b806395d89b41116100bd57806395d89b41146103645780639e4e73181461036c578063a0cc6a681461037457610177565b806370a08231146102fe5780637ecebe001461033157610177565b806323b872dd1161012f578063313ce56711610114578063313ce567146102bb5780633408e470146102d957806342966c68146102e157610177565b806323b872dd1461027057806330adf81f146102b357610177565b8063095ea7b311610160578063095ea7b31461021357806318160ddd1461026057806318369a2a1461026857610177565b806304622c2e1461017c57806306fdde0314610196575b600080fd5b6101846104fd565b60408051918252519081900360200190f35b61019e610521565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d85781810151838201526020016101c0565b50505050905090810190601f1680156102055780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024c6004803603604081101561022957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561055a565b604080519115158252519081900360200190f35b610184610570565b610184610576565b61024c6004803603606081101561028657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610585565b61018461062f565b6102c3610653565b6040805160ff9092168252519081900360200190f35b610184610658565b61024c600480360360208110156102f757600080fd5b503561065c565b6101846004803603602081101561031457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610670565b6101846004803603602081101561034757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610682565b61019e610694565b6101846106cd565b6101846106f1565b61024c6004803603604081101561039257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610715565b610184610722565b61041b600480360360e08110156103d357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135610746565b005b6101846004803603604081101561043357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661086d565b61041b600480360361012081101561046f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060808101359060a08101359060ff60c0820135169060e081013590610100013561088a565b61024c600480360360408110156104da57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610b0a565b7f64c0a41a0260272b78f2a5bd50d5ff7c1779bc3bba16dcff4550c7c642b0e4b481565b6040518060400160405280601481526020017f4865726d657a204e6574776f726b20546f6b656e00000000000000000000000081525081565b6000610567338484610c0f565b50600192915050565b60005481565b6a52b7d2dcc80cd2e400000081565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610619576105e78184610c7e565b73ffffffffffffffffffffffffffffffffffffffff861660009081526002602090815260408083203384529091529020555b610624858585610d1f565b506001949350505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b4690565b60006106683383610e84565b506001919050565b60016020526000908152604090205481565b60036020526000908152604090205481565b6040518060400160405280600381526020017f48455a000000000000000000000000000000000000000000000000000000000081525081565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b7f7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a226781565b6000610567338484610d1f565b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b428410156107b557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f4558504952454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff80881660008181526003602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938a1660608401526080830189905260a083019390935260c08083018890528151808403909101815260e0909201905280519101206108588882868686610f3d565b610863888888610c0f565b5050505050505050565b600260209081526000928352604080842090915290825290205481565b8542116108e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806111db6032913960400191505060405180910390fd5b84421061093a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061118d602c913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8916600090815260046020908152604080832087845290915290205460ff16156109c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806112386031913960400191505060405180910390fd5b604080517f7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a226760208083019190915273ffffffffffffffffffffffffffffffffffffffff808d16838501528b166060830152608082018a905260a0820189905260c0820188905260e0808301889052835180840390910181526101009092019092528051910120610a578a82868686610f3d565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152600460209081526040808320888452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610abb8a8a8a610d1f565b604051859073ffffffffffffffffffffffffffffffffffffffff8c16907f98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a590600090a350505050505050505050565b600460209081526000928352604080842090915290825290205460ff1681565b60408051808201909152601181527f4d4154483a4144445f4f564552464c4f5700000000000000000000000000000060208201528183019083821015610c08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bcd578181015183820152602001610bb5565b50505050905090810190601f168015610bfa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60408051808201909152601281527f4d4154483a5355425f554e444552464c4f57000000000000000000000000000060208201528183039083821115610c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610bcd578181015183820152602001610bb5565b73ffffffffffffffffffffffffffffffffffffffff82163014801590610d5a575073ffffffffffffffffffffffffffffffffffffffff821615155b610daf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806111b96022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054610ddf9082610c7e565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054610e1b9082610b2a565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902054610eb49082610c7e565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554610ee89082610c7e565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f64c0a41a0260272b78f2a5bd50d5ff7c1779bc3bba16dcff4550c7c642b0e4b47fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6610faa610658565b6040805160208082019690965280820194909452606084019290925260808301523060a0808401919091528151808403909101815260c0830182528051908401207f190100000000000000000000000000000000000000000000000000000000000060e084015260e283018190526101028084018a9052825180850390910181526101228401808452815191860191909120600091829052610142850180855281905260ff8a1661016286015261018285018990526101a285018890529251919550919391926001926101c28083019391927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08301929081900390910190855afa1580156110bc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81161580159061113757508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b81526020018061120d602b913960400191505060405180910390fdfe48455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f4558504952454448455a3a3a5f7472616e736665723a204e4f545f56414c49445f5452414e5346455248455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f4e4f545f5945545f56414c494448455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c49445f5349474e415455524548455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f414c52454144595f55534544a2646970667358221220fc8586f479aef614f3de250fad8286dc1fba27d726925b3c464bad2b0ec0723d64736f6c634300060c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106101775760003560e01c806370a08231116100d8578063a9059cbb1161008c578063dd62ed3e11610066578063dd62ed3e1461041d578063e3ee160e14610458578063e94a0102146104c457610177565b8063a9059cbb1461037c578063c473af33146103b5578063d505accf146103bd57610177565b806395d89b41116100bd57806395d89b41146103645780639e4e73181461036c578063a0cc6a681461037457610177565b806370a08231146102fe5780637ecebe001461033157610177565b806323b872dd1161012f578063313ce56711610114578063313ce567146102bb5780633408e470146102d957806342966c68146102e157610177565b806323b872dd1461027057806330adf81f146102b357610177565b8063095ea7b311610160578063095ea7b31461021357806318160ddd1461026057806318369a2a1461026857610177565b806304622c2e1461017c57806306fdde0314610196575b600080fd5b6101846104fd565b60408051918252519081900360200190f35b61019e610521565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101d85781810151838201526020016101c0565b50505050905090810190601f1680156102055780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61024c6004803603604081101561022957600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813516906020013561055a565b604080519115158252519081900360200190f35b610184610570565b610184610576565b61024c6004803603606081101561028657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610585565b61018461062f565b6102c3610653565b6040805160ff9092168252519081900360200190f35b610184610658565b61024c600480360360208110156102f757600080fd5b503561065c565b6101846004803603602081101561031457600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610670565b6101846004803603602081101561034757600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16610682565b61019e610694565b6101846106cd565b6101846106f1565b61024c6004803603604081101561039257600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610715565b610184610722565b61041b600480360360e08110156103d357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135610746565b005b6101846004803603604081101561043357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135811691602001351661086d565b61041b600480360361012081101561046f57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060808101359060a08101359060ff60c0820135169060e081013590610100013561088a565b61024c600480360360408110156104da57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610b0a565b7f64c0a41a0260272b78f2a5bd50d5ff7c1779bc3bba16dcff4550c7c642b0e4b481565b6040518060400160405280601481526020017f4865726d657a204e6574776f726b20546f6b656e00000000000000000000000081525081565b6000610567338484610c0f565b50600192915050565b60005481565b6a52b7d2dcc80cd2e400000081565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610619576105e78184610c7e565b73ffffffffffffffffffffffffffffffffffffffff861660009081526002602090815260408083203384529091529020555b610624858585610d1f565b506001949350505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b4690565b60006106683383610e84565b506001919050565b60016020526000908152604090205481565b60036020526000908152604090205481565b6040518060400160405280600381526020017f48455a000000000000000000000000000000000000000000000000000000000081525081565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b7f7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a226781565b6000610567338484610d1f565b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b428410156107b557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f48455a3a3a7065726d69743a20415554485f4558504952454400000000000000604482015290519081900360640190fd5b73ffffffffffffffffffffffffffffffffffffffff80881660008181526003602090815260409182902080546001810190915582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98184015280840194909452938a1660608401526080830189905260a083019390935260c08083018890528151808403909101815260e0909201905280519101206108588882868686610f3d565b610863888888610c0f565b5050505050505050565b600260209081526000928352604080842090915290825290205481565b8542116108e2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001806111db6032913960400191505060405180910390fd5b84421061093a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c81526020018061118d602c913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8916600090815260046020908152604080832087845290915290205460ff16156109c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260318152602001806112386031913960400191505060405180910390fd5b604080517f7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a226760208083019190915273ffffffffffffffffffffffffffffffffffffffff808d16838501528b166060830152608082018a905260a0820189905260c0820188905260e0808301889052835180840390910181526101009092019092528051910120610a578a82868686610f3d565b73ffffffffffffffffffffffffffffffffffffffff8a166000908152600460209081526040808320888452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055610abb8a8a8a610d1f565b604051859073ffffffffffffffffffffffffffffffffffffffff8c16907f98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a590600090a350505050505050505050565b600460209081526000928352604080842090915290825290205460ff1681565b60408051808201909152601181527f4d4154483a4144445f4f564552464c4f5700000000000000000000000000000060208201528183019083821015610c08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610bcd578181015183820152602001610bb5565b50505050905090810190601f168015610bfa5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5092915050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b60408051808201909152601281527f4d4154483a5355425f554e444552464c4f57000000000000000000000000000060208201528183039083821115610c08576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201818152835160248401528351909283926044909101919085019080838360008315610bcd578181015183820152602001610bb5565b73ffffffffffffffffffffffffffffffffffffffff82163014801590610d5a575073ffffffffffffffffffffffffffffffffffffffff821615155b610daf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806111b96022913960400191505060405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054610ddf9082610c7e565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054610e1b9082610b2a565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260016020526040902054610eb49082610c7e565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554610ee89082610c7e565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7f64c0a41a0260272b78f2a5bd50d5ff7c1779bc3bba16dcff4550c7c642b0e4b47fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6610faa610658565b6040805160208082019690965280820194909452606084019290925260808301523060a0808401919091528151808403909101815260c0830182528051908401207f190100000000000000000000000000000000000000000000000000000000000060e084015260e283018190526101028084018a9052825180850390910181526101228401808452815191860191909120600091829052610142850180855281905260ff8a1661016286015261018285018990526101a285018890529251919550919391926001926101c28083019391927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08301929081900390910190855afa1580156110bc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81161580159061113757508773ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b610863576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b81526020018061120d602b913960400191505060405180910390fdfe48455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f4558504952454448455a3a3a5f7472616e736665723a204e4f545f56414c49445f5452414e5346455248455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f4e4f545f5945545f56414c494448455a3a3a5f76616c69646174655369676e6564446174613a20494e56414c49445f5349474e415455524548455a3a3a7472616e7366657257697468417574686f72697a6174696f6e3a20415554485f414c52454144595f55534544a2646970667358221220fc8586f479aef614f3de250fad8286dc1fba27d726925b3c464bad2b0ec0723d64736f6c634300060c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/eth/contracts/abi/Hermez.json b/eth/contracts/abi/Hermez.json new file mode 100644 index 000000000..5ab8cf192 --- /dev/null +++ b/eth/contracts/abi/Hermez.json @@ -0,0 +1,1246 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "Hermez", + "sourceName": "contracts/hermez/Hermez.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "tokenID", + "type": "uint32" + } + ], + "name": "AddToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "batchNum", + "type": "uint32" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "l1UserTxsLen", + "type": "uint16" + } + ], + "name": "ForgeBatch", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "forgeL1L2BatchTimeout", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAddToken", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "withdrawalDelay", + "type": "uint64" + } + ], + "name": "InitializeHermezEvent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint32", + "name": "queueIndex", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "uint8", + "name": "position", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "l1UserTx", + "type": "bytes" + } + ], + "name": "L1UserTxEvent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "SafeMode", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint8", + "name": "numBucket", + "type": "uint8" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "blockStamp", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawals", + "type": "uint256" + } + ], + "name": "UpdateBucketWithdraw", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256[]", + "name": "arrayBuckets", + "type": "uint256[]" + } + ], + "name": "UpdateBucketsParameters", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeAddToken", + "type": "uint256" + } + ], + "name": "UpdateFeeAddToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "newForgeL1L2BatchTimeout", + "type": "uint8" + } + ], + "name": "UpdateForgeL1L2BatchTimeout", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address[]", + "name": "addressArray", + "type": "address[]" + }, + { + "indexed": false, + "internalType": "uint64[]", + "name": "valueArray", + "type": "uint64[]" + } + ], + "name": "UpdateTokenExchange", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "newWithdrawalDelay", + "type": "uint64" + } + ], + "name": "UpdateWithdrawalDelay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint48", + "name": "idx", + "type": "uint48" + }, + { + "indexed": true, + "internalType": "uint32", + "name": "numExitRoot", + "type": "uint32" + }, + { + "indexed": true, + "internalType": "bool", + "name": "instantWithdraw", + "type": "bool" + } + ], + "name": "WithdrawEvent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "hermezV2", + "type": "event" + }, + { + "inputs": [], + "name": "ABSOLUTE_MAX_L1L2BATCHTIMEOUT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ACCOUNT_CREATION_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "AUTHORISE_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "domainSeparator", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "EIP712DOMAIN_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "HERMEZ_NETWORK_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "NAME_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VERSION_HASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "babyPubKey", + "type": "uint256" + }, + { + "internalType": "uint48", + "name": "fromIdx", + "type": "uint48" + }, + { + "internalType": "uint40", + "name": "loadAmountF", + "type": "uint40" + }, + { + "internalType": "uint40", + "name": "amountF", + "type": "uint40" + }, + { + "internalType": "uint32", + "name": "tokenID", + "type": "uint32" + }, + { + "internalType": "uint48", + "name": "toIdx", + "type": "uint48" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "addL1Transaction", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "addToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + } + ], + "name": "buckets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + }, + { + "internalType": "uint48", + "name": "", + "type": "uint48" + } + ], + "name": "exitNullifierMap", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "exitRootsMap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeAddToken", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint48", + "name": "newLastIdx", + "type": "uint48" + }, + { + "internalType": "uint256", + "name": "newStRoot", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "newExitRoot", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "encodedL1CoordinatorTx", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "l1L2TxsData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "feeIdxCoordinator", + "type": "bytes" + }, + { + "internalType": "uint8", + "name": "verifierIdx", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "l1Batch", + "type": "bool" + }, + { + "internalType": "uint256[2]", + "name": "proofA", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "proofB", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "proofC", + "type": "uint256[2]" + } + ], + "name": "forgeBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "forgeL1L2BatchTimeout", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [ + { + "internalType": "uint256", + "name": "chainId", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "hermezAuctionContract", + "outputs": [ + { + "internalType": "contract IHermezAuctionProtocol", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hermezGovernanceAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "_verifiers", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "_verifiersParams", + "type": "uint256[]" + }, + { + "internalType": "address", + "name": "_withdrawVerifier", + "type": "address" + }, + { + "internalType": "address", + "name": "_hermezAuctionContract", + "type": "address" + }, + { + "internalType": "address", + "name": "_tokenHEZ", + "type": "address" + }, + { + "internalType": "uint8", + "name": "_forgeL1L2BatchTimeout", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "_feeAddToken", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_poseidon2Elements", + "type": "address" + }, + { + "internalType": "address", + "name": "_poseidon3Elements", + "type": "address" + }, + { + "internalType": "address", + "name": "_poseidon4Elements", + "type": "address" + }, + { + "internalType": "address", + "name": "_hermezGovernanceAddress", + "type": "address" + }, + { + "internalType": "uint64", + "name": "_withdrawalDelay", + "type": "uint64" + }, + { + "internalType": "address", + "name": "_withdrawDelayerContract", + "type": "address" + } + ], + "name": "initializeHermez", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "tokenAddress", + "type": "address" + }, + { + "internalType": "uint192", + "name": "amount", + "type": "uint192" + } + ], + "name": "instantWithdrawalViewer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "l1L2TxsDataHashMap", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastForgedBatch", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastIdx", + "outputs": [ + { + "internalType": "uint48", + "name": "", + "type": "uint48" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "lastL1L2Batch", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "mapL1TxQueue", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nBuckets", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextL1FillingQueue", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nextL1ToForgeQueue", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "ceilUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "blockStamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rateBlocks", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rateWithdrawals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxWithdrawals", + "type": "uint256" + } + ], + "name": "packBucket", + "outputs": [ + { + "internalType": "uint256", + "name": "ret", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "registerTokensCount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "rollupVerifiers", + "outputs": [ + { + "internalType": "contract VerifierRollupInterface", + "name": "verifierInterface", + "type": "address" + }, + { + "internalType": "uint256", + "name": "maxTx", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "nLevels", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rollupVerifiersLength", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "safeMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "name": "stateRootMap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenExchange", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenHEZ", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "tokenList", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "tokenMap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "bucket", + "type": "uint256" + } + ], + "name": "unpackBucket", + "outputs": [ + { + "internalType": "uint256", + "name": "ceilUSD", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "blockStamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "withdrawals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rateBlocks", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rateWithdrawals", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxWithdrawals", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[]", + "name": "newBuckets", + "type": "uint256[]" + } + ], + "name": "updateBucketsParameters", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newFeeAddToken", + "type": "uint256" + } + ], + "name": "updateFeeAddToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "newForgeL1L2BatchTimeout", + "type": "uint8" + } + ], + "name": "updateForgeL1L2BatchTimeout", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "addressArray", + "type": "address[]" + }, + { + "internalType": "uint64[]", + "name": "valueArray", + "type": "uint64[]" + } + ], + "name": "updateTokenExchange", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateVerifiers", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "newWithdrawalDelay", + "type": "uint64" + } + ], + "name": "updateWithdrawalDelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256[2]", + "name": "proofA", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2][2]", + "name": "proofB", + "type": "uint256[2][2]" + }, + { + "internalType": "uint256[2]", + "name": "proofC", + "type": "uint256[2]" + }, + { + "internalType": "uint32", + "name": "tokenID", + "type": "uint32" + }, + { + "internalType": "uint192", + "name": "amount", + "type": "uint192" + }, + { + "internalType": "uint32", + "name": "numExitRoot", + "type": "uint32" + }, + { + "internalType": "uint48", + "name": "idx", + "type": "uint48" + }, + { + "internalType": "bool", + "name": "instantWithdraw", + "type": "bool" + } + ], + "name": "withdrawCircuit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawDelayerContract", + "outputs": [ + { + "internalType": "contract IWithdrawalDelayer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "tokenID", + "type": "uint32" + }, + { + "internalType": "uint192", + "name": "amount", + "type": "uint192" + }, + { + "internalType": "uint256", + "name": "babyPubKey", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "numExitRoot", + "type": "uint32" + }, + { + "internalType": "uint256[]", + "name": "siblings", + "type": "uint256[]" + }, + { + "internalType": "uint48", + "name": "idx", + "type": "uint48" + }, + { + "internalType": "bool", + "name": "instantWithdraw", + "type": "bool" + } + ], + "name": "withdrawMerkleProof", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawVerifier", + "outputs": [ + { + "internalType": "contract VerifierWithdrawInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawalDelay", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50615f4680620000216000396000f3fe6080604052600436106102e35760003560e01c8063864eb16411610190578063c473af33116100dc578063d486645c11610095578063e62f6b921161006f578063e62f6b921461106f578063ef4a5c4a14611084578063f1f2fcab1461035e578063f84f92ee146110b7576102e3565b8063d486645c14610eb3578063d9d4ca4414610ee3578063dc3e718e14610fca576102e3565b8063c473af3314610d34578063c727305314610d49578063cbd7b5fb14610df9578063ccd226a714610e26578063ce5ec65a14610e6e578063d0f32e6714610e9e576102e3565b80639ead722211610149578063a7ab696111610123578063a7ab696114610c47578063abe3219c14610c5c578063ac300ec914610c71578063bded9bb814610d1f576102e3565b80639ead722214610bf35780639f34e9a314610c1d578063a327583814610c32576102e3565b8063864eb16414610aec57806395a09f2a14610b01578063960207c014610b2c5780639ce2ad4214610b415780639e00d7ea14610bae5780639e4e731814610bde576102e3565b80633408e4701161024f57806344e0b2ce1161020857806370c2f1c0116101e257806370c2f1c014610a2257806379a135e314610aad5780637ba3a5e014610ac257806384ef9ed414610ad7576102e3565b806344e0b2ce14610729578063599897e31461073e5780636e7e1365146108d0576102e3565b80633408e470146105ca5780633644e515146105df578063375110aa146105f4578063383302001461064a5780633ee641ea1461069c5780633f267155146106cc576102e3565b80630ee8e52b116102a15780630ee8e52b146104015780631300aff01461042f5780631a748c2d146104445780631b0a8223146105765780632bd836261461058b578063314e5eda146105a0576102e3565b80624aca6e146102e8578063013f78521461032d57806304622c2e1461035e578063061d09641461037357806307feef6e1461039d5780630dd94b96146103b2575b600080fd5b3480156102f457600080fd5b5061031b6004803603602081101561030b57600080fd5b50356001600160a01b03166110f5565b60408051918252519081900360200190f35b34801561033957600080fd5b50610342611107565b604080516001600160a01b039092168252519081900360200190f35b34801561036a57600080fd5b5061031b611116565b34801561037f57600080fd5b5061031b6004803603602081101561039657600080fd5b503561113a565b3480156103a957600080fd5b5061031b61114c565b3480156103be57600080fd5b506103e5600480360360208110156103d557600080fd5b50356001600160a01b0316611152565b604080516001600160401b039092168252519081900360200190f35b34801561040d57600080fd5b5061041661116d565b6040805163ffffffff9092168252519081900360200190f35b34801561043b57600080fd5b5061031b611180565b34801561045057600080fd5b506105746004803603604081101561046757600080fd5b810190602081018135600160201b81111561048157600080fd5b82018360208201111561049357600080fd5b803590602001918460208302840111600160201b831117156104b457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561050357600080fd5b82018360208201111561051557600080fd5b803590602001918460208302840111600160201b8311171561053657600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506111a4945050505050565b005b34801561058257600080fd5b50610342611367565b34801561059757600080fd5b50610342611376565b3480156105ac57600080fd5b50610574600480360360208110156105c357600080fd5b5035611385565b3480156105d657600080fd5b5061031b611409565b3480156105eb57600080fd5b5061031b61140d565b34801561060057600080fd5b506106366004803603604081101561061757600080fd5b5080356001600160a01b031690602001356001600160c01b03166114cb565b604080519115158252519081900360200190f35b34801561065657600080fd5b506106746004803603602081101561066d57600080fd5b50356115ac565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b3480156106a857600080fd5b5061031b600480360360208110156106bf57600080fd5b503563ffffffff166115e6565b3480156106d857600080fd5b506106f6600480360360208110156106ef57600080fd5b50356115f8565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b34801561073557600080fd5b5061041661162d565b34801561074a57600080fd5b5061057460048036036101a081101561076257600080fd5b810190602081018135600160201b81111561077c57600080fd5b82018360208201111561078e57600080fd5b803590602001918460208302840111600160201b831117156107af57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156107fe57600080fd5b82018360208201111561081057600080fd5b803590602001918460208302840111600160201b8311171561083157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b03833581169450602084013581169360408101358216935060ff606082013516925060808101359160a082013581169160c081013582169160e08201358116916101008101358216916001600160401b036101208301351691610140013516611640565b3480156108dc57600080fd5b5061057460048036036102008110156108f457600080fd5b65ffffffffffff8235169160208101359160408201359190810190608081016060820135600160201b81111561092957600080fd5b82018360208201111561093b57600080fd5b803590602001918460018302840111600160201b8311171561095c57600080fd5b919390929091602081019035600160201b81111561097957600080fd5b82018360208201111561098b57600080fd5b803590602001918460018302840111600160201b831117156109ac57600080fd5b919390929091602081019035600160201b8111156109c957600080fd5b8201836020820111156109db57600080fd5b803590602001918460018302840111600160201b831117156109fc57600080fd5b919350915060ff81351690602081013515159060408101906080810190610100016118de565b348015610a2e57600080fd5b5061057460048036036040811015610a4557600080fd5b6001600160a01b038235169190810190604081016020820135600160201b811115610a6f57600080fd5b820183602082011115610a8157600080fd5b803590602001918460018302840111600160201b83111715610aa257600080fd5b509092509050611dc8565b348015610ab957600080fd5b50610342612051565b348015610ace57600080fd5b5061031b612060565b348015610ae357600080fd5b506103e5612066565b348015610af857600080fd5b50610342612075565b348015610b0d57600080fd5b50610b16612084565b6040805160ff9092168252519081900360200190f35b348015610b3857600080fd5b50610574612089565b348015610b4d57600080fd5b5061057460048036036101a0811015610b6557600080fd5b506040810160c0820163ffffffff6101008401358116906001600160c01b0361012086013516906101408601351665ffffffffffff6101608701351661018087013515156122a8565b348015610bba57600080fd5b5061031b60048036036020811015610bd157600080fd5b503563ffffffff1661267b565b348015610bea57600080fd5b5061031b61268d565b348015610bff57600080fd5b5061034260048036036020811015610c1657600080fd5b50356126b1565b348015610c2957600080fd5b5061031b6126d8565b348015610c3e57600080fd5b50610b166126de565b348015610c5357600080fd5b506103e56126ee565b348015610c6857600080fd5b50610574612704565b348015610c7d57600080fd5b5061057460048036036020811015610c9457600080fd5b810190602081018135600160201b811115610cae57600080fd5b820183602082011115610cc057600080fd5b803590602001918460208302840111600160201b83111715610ce157600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061283e945050505050565b348015610d2b57600080fd5b5061031b612a2e565b348015610d4057600080fd5b5061031b612a34565b610574600480360360e0811015610d5f57600080fd5b81359165ffffffffffff602082013581169264ffffffffff604084013581169360608101359091169263ffffffff6080830135169260a0830135909116919081019060e0810160c0820135600160201b811115610dbb57600080fd5b820183602082011115610dcd57600080fd5b803590602001918460018302840111600160201b83111715610dee57600080fd5b509092509050612a58565b348015610e0557600080fd5b5061057460048036036020811015610e1c57600080fd5b503560ff16612d6e565b348015610e3257600080fd5b5061031b600480360360c0811015610e4957600080fd5b5080359060208101359060408101359060608101359060808101359060a00135612e4e565b348015610e7a57600080fd5b5061031b60048036036020811015610e9157600080fd5b503563ffffffff16612e7b565b348015610eaa57600080fd5b50610416612e8d565b348015610ebf57600080fd5b50610ec8612ea0565b6040805165ffffffffffff9092168252519081900360200190f35b348015610eef57600080fd5b50610574600480360360e0811015610f0657600080fd5b63ffffffff82358116926001600160c01b0360208201351692604082013592606083013516919081019060a081016080820135600160201b811115610f4a57600080fd5b820183602082011115610f5c57600080fd5b803590602001918460208302840111600160201b83111715610f7d57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505065ffffffffffff83351693505050602001351515612eb5565b348015610fd657600080fd5b50610ffa60048036036020811015610fed57600080fd5b503563ffffffff166130a5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561103457818101518382015260200161101c565b50505050905090810190601f1680156110615780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561107b57600080fd5b5061031b613140565b34801561109057600080fd5b50610574600480360360208110156110a757600080fd5b50356001600160401b0316613164565b3480156110c357600080fd5b50610636600480360360408110156110da57600080fd5b50803563ffffffff16906020013565ffffffffffff16613259565b600f6020526000908152604090205481565b6005546001600160a01b031681565b7fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad81565b60046020526000908152604090205481565b60035481565b6007602052600090815260409020546001600160401b031681565b601354600160601b900463ffffffff1681565b7fff946cf82975b1a2b6e6d28c9a76a4b8d7a1fd0592b785cb92771933310f9ee781565b6005546001600160a01b031633146111ed5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b805182511461122d5760405162461bcd60e51b815260040180806020018281038252604181526020018061556b6041913960600191505060405180910390fd5b60005b82518110156112a75781818151811061124557fe5b60200260200101516007600085848151811061125d57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805467ffffffffffffffff19166001600160401b0392909216919091179055600101611230565b507f10ff643ebeca3e33002e61b76fa85e7e10091e30afa39295f91af9838b3033b38282604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561130f5781810151838201526020016112f7565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561134e578181015183820152602001611336565b5050505090500194505050505060405180910390a15050565b6006546001600160a01b031681565b6011546001600160a01b031681565b6005546001600160a01b031633146113ce5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b60108190556040805182815290517fd1c873cd16013f0dc5f37992c0d12794389698512895ec036a568e393b46e3c19181900360200190a150565b4690565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661147a611409565b3060405160200180868152602001858152602001848152602001838152602001826001600160a01b031681526020019550505050505060405160208183030381529060405280519060200120905090565b6000806114d88484613279565b9050806114e95760019150506115a6565b60006114f482613438565b905080600019141561150b576001925050506115a6565b600080600080600061152f60046000888152602001908152602001600020546115f8565b9550955095509550955050600061154f864361349590919063ffffffff16565b9050600061155d82866134de565b905061157361156c8286613520565b8790613579565b955082861115611581578295505b8561159857600099505050505050505050506115a6565b600199505050505050505050505b92915050565b600881815481106115b957fe5b60009182526020909120600390910201805460018201546002909201546001600160a01b03909116925083565b600b6020526000908152604090205481565b6001600160601b0381169163ffffffff606083901c811692608081901c82169260a082901c83169260c083901c169160e01c90565b600954600160d01b900463ffffffff1681565b600054610100900460ff168061165957506116596135d3565b80611667575060005460ff16155b6116a25760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff161580156116cd576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038b16158015906116ed57506001600160a01b03821615155b6117285760405162461bcd60e51b815260040180806020018281038252602c81526020018061588d602c913960400191505060405180910390fd5b6117328e8e6135d9565b8b600960006101000a8154816001600160a01b0302191690836001600160a01b031602179055508a601160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555089601460006101000a8154816001600160a01b0302191690836001600160a01b0316021790555088601360106101000a81548160ff021916908360ff1602179055508760108190555060ff600960146101000a81548165ffffffffffff021916908365ffffffffffff16021790555060016013600c6101000a81548163ffffffff021916908363ffffffff160217905550600e60009080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055506118668787876136aa565b6118718484846137a0565b6040805160ff8b168152602081018a90526001600160401b0385168183015290517fc5272ad4c8d9f2e9af2f9555c11ead049be22b6e45c16975adc82371b7cd10409181900360600190a180156118ce576000805461ff00191690555b5050505050505050505050505050565b33321461191c5760405162461bcd60e51b815260040180806020018281038252602a815260200180615842602a913960400191505060405180910390fd5b6011546040805163041d8fb560e51b815233600482015243602482015290516001600160a01b03909216916383b1f6a091604480820192602092909190829003018186803b15801561196d57600080fd5b505afa158015611981573d6000803e3d6000fd5b505050506040513d602081101561199757600080fd5b505115156001146119d95760405162461bcd60e51b81526004018080602001828103825260228152602001806157416022913960400191505060405180910390fd5b83611a3557601354600160801b810460ff166001600160401b0391821601164310611a355760405162461bcd60e51b8152600401808060200182810382526026815260200180615c266026913960400191505060405180910390fd5b6000611a448f8f8f888a613895565b905060088660ff1681548110611a5657fe5b60009182526020918290206003909102015460408051928301815283835280516343753b4d60e01b81526001600160a01b03909216926343753b4d9288928892889290916004909101908190869080828437600083820152601f01601f1916909101905084608080828437600083820152601f01601f1916909101905083604080828437600081840152601f19601f82011690508083019250505082600160200280838360005b83811015611b15578181015183820152602001611afd565b5050505090500194505050505060206040518083038186803b158015611b3a57600080fd5b505afa158015611b4e573d6000803e3d6000fd5b505050506040513d6020811015611b6457600080fd5b5051611ba15760405162461bcd60e51b81526004018080602001828103825260218152602001806155e86021913960400191505060405180910390fd5b6009601a81819054906101000a900463ffffffff168092919060010191906101000a81548163ffffffff021916908363ffffffff160217905550508e600960146101000a81548165ffffffffffff021916908365ffffffffffff1602179055508d600a60006009601a9054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001908152602001600020819055508c600b60006009601a9054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020019081526020016000208190555060028a8a6040518083838082843760405192019450602093509091505080830381855afa158015611ca2573d6000803e3d6000fd5b5050506040513d6020811015611cb757600080fd5b5051600954600160d01b900463ffffffff166000908152600c60205260408120919091558515611d08576013805467ffffffffffffffff1916436001600160401b0316179055611d05613b71565b90505b601154604080516309cb4a2f60e31b815233600482015290516001600160a01b0390921691634e5a51789160248082019260009290919082900301818387803b158015611d5457600080fd5b505af1158015611d68573d6000803e3d6000fd5b50506009546040805161ffff861681529051600160d01b90920463ffffffff1693507fe00040c8a3b0bf905636c26924e90520eafc5003324138236fddee2d3458861892506020908290030190a250505050505050505050505050505050565b6000836001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0357600080fd5b505afa158015611e17573d6000803e3d6000fd5b505050506040513d6020811015611e2d57600080fd5b505111611e6b5760405162461bcd60e51b8152600401808060200182810382526023815260200180615cf86023913960400191505060405180910390fd5b600e54600160201b8110611eb05760405162461bcd60e51b815260040180806020018281038252602181526020018061586c6021913960400191505060405180910390fd5b6001600160a01b038416611ef55760405162461bcd60e51b81526004018080602001828103825260238152602001806157ee6023913960400191505060405180910390fd5b6001600160a01b0384166000908152600f602052604090205415611f60576040805162461bcd60e51b815260206004820152601f60248201527f4865726d657a3a3a616464546f6b656e3a20414c52454144595f414444454400604482015290519081900360640190fd5b6005546001600160a01b03163314611fb6578115611f9357601454601054611f93916001600160a01b0316908585613c2e565b601454600554601054611fb6926001600160a01b03908116923392911690613ef7565b600e8054600181019091557fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319166001600160a01b0386169081179091556000818152600f6020908152604091829020849055815163ffffffff8516815291517fcb73d161edb7cd4fb1d92fedfd2555384fd997fd44ab507656f8c81e15747dde9281900390910190a250505050565b6014546001600160a01b031681565b60085490565b6013546001600160401b031681565b6009546001600160a01b031681565b60f081565b3373b6d3f1056c015962fa66a4020e50522b58292d1e146120db5760405162461bcd60e51b8152600401808060200182810382526025815260200180615a056025913960400191505060405180910390fd5b60086000815481106120e957fe5b9060005260206000209060030201600101546101581461213a5760405162461bcd60e51b81526004018080602001828103825260318152602001806158116031913960400191505060405180910390fd5b6040518060600160405280733daa0b2a994b1bc60db9e312ad0a8d87a1bb16d26001600160a01b0316815260200161019081526020016020815250600860008154811061218357fe5b906000526020600020906003020160008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201559050506040518060600160405280731dc4b451dfcd0e848881ede8c7a99978f00b13426001600160a01b0316815260200161080081526020016020815250600860018154811061221e57fe5b60009182526020808320845160039093020180546001600160a01b039093166001600160a01b031993841617815590840151600182015560409384015160029091015560098054909116734464a1e499cf5443541da6728871af1d5c4920ca17905590517fd5303fa2e7ece2a0fe77fbba1df5bb224b461198dd7bfd7fe0071f964c86c6739190a1565b801561231a576122df600e8663ffffffff16815481106122c457fe5b6000918252602090912001546001600160a01b031685614054565b61231a5760405162461bcd60e51b8152600401808060200182810382526043815260200180615ad56043913960600191505060405180910390fd5b63ffffffff83166000908152600d6020908152604080832065ffffffffffff8616845290915290205460ff16156123825760405162461bcd60e51b815260040180806020018281038252602e815260200180615a7d602e913960400191505060405180910390fd5b63ffffffff83166000908152600b602090815260408083205481518084018290523360601b818401526001600160e01b031960e08b901b16605482015267ffffffffffffffff1989841b1660588201526001600160d01b031960d088901b1660708201528251605681830301815260769091019283905280519194937f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000019360029390918291908401908083835b6020831061244e5780518252601f19909201916020918201910161242f565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa15801561248d573d6000803e3d6000fd5b5050506040513d60208110156124a257600080fd5b5051816124ab57fe5b600954604080516020810182529390920680845282516343753b4d60e01b81529094506001600160a01b03909116926343753b4d928e928e928e929091600401908190869080828437600083820152601f01601f1916909101905084608080828437600083820152601f01601f1916909101905083604080828437600081840152601f19601f82011690508083019250505082600160200280838360005b83811015612561578181015183820152602001612549565b5050505090500194505050505060206040518083038186803b15801561258657600080fd5b505afa15801561259a573d6000803e3d6000fd5b505050506040513d60208110156125b057600080fd5b505115156001146125f25760405162461bcd60e51b8152600401808060200182810382526029815260200180615ba66029913960400191505060405180910390fd5b63ffffffff85166000908152600d6020908152604080832065ffffffffffff881684529091529020805460ff191660011790556126308688856141bb565b8215158563ffffffff168565ffffffffffff167f69177d798b38e27bcc4e0338307e4f1490e12d1006729d0e6e9cc82a8732f41560405160405180910390a450505050505050505050565b600a6020526000908152604090205481565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b600e81815481106126be57fe5b6000918252602090912001546001600160a01b0316905081565b600e5490565b601354600160801b900460ff1681565b600554600160a01b90046001600160401b031681565b6005546001600160a01b0316331461274d5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b600160038190555061276d6001600160601b036000806001600080612e4e565b6000808052600460208190527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec9290925560065460055460408051630e670af560e01b8152600160a01b9092046001600160401b03169482019490945292516001600160a01b0390911692630e670af592602480830193919282900301818387803b1580156127fb57600080fd5b505af115801561280f573d6000803e3d6000fd5b50506040517f0410e6ef2bd89ecf5b2dc2f62157f9863e09e89cb7c7f1abb7d4ec43a6019d1e925060009150a1565b6005546001600160a01b031633146128875760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b805160058111156128c95760405162461bcd60e51b81526004018080602001828103825260408152602001806157016040913960400191505060405180910390fd5b600381905560005b818110156129b45760008060008060006128fd8887815181106128f057fe5b60200260200101516115f8565b9550955095509550509450808411156129475760405162461bcd60e51b815260040180806020018281038252605d815260200180615d88605d913960600191505060405180910390fd5b600083116129865760405162461bcd60e51b8152600401808060200182810382526050815260200180615ca86050913960600191505060405180910390fd5b612994854386868686612e4e565b6000878152600460205260409020555050600190930192506128d1915050565b507fd4904145d7eae889c5493798579680417459783db0fa67398bea50e56859075f826040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015612a175781810151838201526020016129ff565b505050509050019250505060405180910390a15050565b60105481565b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b600e5463ffffffff851610612a9e5760405162461bcd60e51b815260040180806020018281038252602e815260200180615c4c602e913960400191505060405180910390fd5b6000612aa987614355565b9050600160801b8110612aed5760405162461bcd60e51b81526004018080602001828103825260318152602001806156096031913960400191505060405180910390fd5b8015612d545763ffffffff8516612b4157348114612b3c5760405162461bcd60e51b8152600401808060200182810382526037815260200180615eda6037913960400191505060405180910390fd5b612d54565b3415612b7e5760405162461bcd60e51b815260040180806020018281038252602f815260200180615936602f913960400191505060405180910390fd5b8115612bb757612bb7600e8663ffffffff1681548110612b9a57fe5b6000918252602090912001546001600160a01b0316828585613c2e565b6000600e8663ffffffff1681548110612bcc57fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015612c1b57600080fd5b505afa158015612c2f573d6000803e3d6000fd5b505050506040513d6020811015612c4557600080fd5b5051600e8054919250612c7f9163ffffffff8916908110612c6257fe5b6000918252602090912001546001600160a01b0316333085613ef7565b6000600e8763ffffffff1681548110612c9457fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015612ce357600080fd5b505afa158015612cf7573d6000803e3d6000fd5b505050506040513d6020811015612d0d57600080fd5b505190508181038314612d515760405162461bcd60e51b8152600401808060200182810382526039815260200180615e0f6039913960400191505060405180910390fd5b50505b612d63338a8a8a8a8a8a61436d565b505050505050505050565b6005546001600160a01b03163314612db75760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b60f060ff82161115612dfa5760405162461bcd60e51b815260040180806020018281038252603c8152602001806155ac603c913960400191505060405180910390fd5b6013805460ff8316600160801b810260ff60801b199092169190911790915560408051918252517fff6221781ac525b04585dbb55cd2ebd2a92c828ca3e42b23813a1137ac9744319181900360200190a150565b600060e082901b60c084901b60a086901b608088901b60608a901b8b171717171790509695505050505050565b600c6020526000908152604090205481565b601354600160401b900463ffffffff1681565b600954600160a01b900465ffffffffffff1681565b8015612f2757612eec600e8863ffffffff1681548110612ed157fe5b6000918252602090912001546001600160a01b031687614054565b612f275760405162461bcd60e51b81526004018080602001828103825260478152602001806159656047913960600191505060405180910390fd5b612f2f61540d565b612f46886000896001600160c01b031689336145ca565b90506000612f538261462c565b63ffffffff87166000908152600b6020908152604080832054600d835281842065ffffffffffff8a168552909252909120549192509060ff1615612fc85760405162461bcd60e51b8152600401808060200182810382526032815260200180615a2a6032913960400191505060405180910390fd5b612fdc81878765ffffffffffff16856146c9565b151560011461301c5760405162461bcd60e51b815260040180806020018281038252602e815260200180615c7a602e913960400191505060405180910390fd5b63ffffffff87166000908152600d6020908152604080832065ffffffffffff891684529091529020805460ff1916600117905561305a898b866141bb565b8315158763ffffffff168665ffffffffffff167f69177d798b38e27bcc4e0338307e4f1490e12d1006729d0e6e9cc82a8732f41560405160405180910390a450505050505050505050565b60126020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156131385780601f1061310d57610100808354040283529160200191613138565b820191906000526020600020905b81548152906001019060200180831161311b57829003601f168201915b505050505081565b7fafd642c6a37a2e6887dc4ad5142f84197828a904e53d3204ecb1100329231eaa81565b6005546001600160a01b031633146131ad5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b62127500816001600160401b031611156131f85760405162461bcd60e51b815260040180806020018281038252604a815260200180615763604a913960600191505060405180910390fd5b600580546001600160401b038316600160a01b810267ffffffffffffffff60a01b199092169190911790915560408051918252517f9db302c4547a21fb20a3a794e5f63ee87eb6e4afc3325ebdadba2d1fb4a907379181900360200190a150565b600d60209081526000928352604080842090915290825290205460ff1681565b6001600160a01b0382166000908152600760205260408120546001600160401b03166132a7575060006115a6565b6001600160a01b0383166000818152600760205260408120546402540be4006001600160401b039091166001600160c01b0386160204916132ea575060126133dd565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b178152915181516000936060936001600160a01b038b16939092909182918083835b602083106133505780518252601f199092019160209182019101613331565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146133b0576040519150601f19603f3d011682016040523d82523d6000602084013e6133b5565b606091505b509150915081156133da578080602001905160208110156133d557600080fd5b505192505b50505b604d8160ff161061341f5760405162461bcd60e51b815260040180806020018281038252603b8152602001806154f0603b913960400191505060405180910390fd5b8060ff16600a0a828161342e57fe5b0495945050505050565b6000805b600354811215613489576000818152600460205260409020546001600160601b031680841115806134735750806001600160601b03145b1561348057509050613490565b5060010161343c565b5060001990505b919050565b60006134d783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614750565b9392505050565b60006134d783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506147e7565b60008261352f575060006115a6565b8282028284828161353c57fe5b04146134d75760405162461bcd60e51b8152600401808060200182810382526021815260200180615a5c6021913960400191505060405180910390fd5b6000828201838110156134d7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b303b1590565b60005b82518110156136a557600860405180606001604052808584815181106135fe57fe5b60200260200101516001600160a01b0316815260200160088086868151811061362357fe5b6020026020010151901b901c815260200160f885858151811061364257fe5b60209081029190910181015190911c909152825460018082018555600094855293829020835160039092020180546001600160a01b0319166001600160a01b039092169190911781559082015181840155604090910151600290910155016135dc565b505050565b600054610100900460ff16806136c357506136c36135d3565b806136d1575060005460ff16155b61370c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff16158015613737576000805460ff1961ff0019909116610100171660011790555b600080546001600160a01b03808716620100000262010000600160b01b031990921691909117909155600180548583166001600160a01b0319918216179091556002805492851692909116919091179055801561379a576000805461ff00191690555b50505050565b600054610100900460ff16806137b957506137b96135d3565b806137c7575060005460ff16155b6138025760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff1615801561382d576000805460ff1961ff0019909116610100171660011790555b600580546001600160a01b03199081166001600160a01b038781169190911767ffffffffffffffff60a01b1916600160a01b6001600160401b038816021790925560068054909116918416919091179055801561379a576000805461ff001916905550505050565b600954600160d01b810463ffffffff166000908152600a60205260408120546008805492939192600160a01b90920465ffffffffffff16918491829182919060ff89169081106138e157fe5b9060005260206000209060030201600101546008808960ff168154811061390457fe5b9060005260206000209060030201600201548161391d57fe5b0460020260050160010102905060006008808960ff168154811061393d57fe5b9060005260206000209060030201600201548161395657fe5b60408051929091048102848101808401614eb201909252614e72909101825260d087811b60208401528e901b6026830152602c8201889052604c82018d9052606c82018c90529150608c81016139ac818c614842565b614e00016139ba6004614a79565b9096509450838511156139fe5760405162461bcd60e51b815260040180806020018281038252602e815260200180615d1b602e913960400191505060405180910390fd5b848682378401613a1081868603614a8d565b84840301613a1e6005614a79565b909650945082851115613a625760405162461bcd60e51b815260040180806020018281038252604081526020018061552b6040913960400191505060405180910390fd5b848682378401613a7481868503614a8d565b848303810190504660f01b815260028101905060006009601a9054906101000a900463ffffffff1660010163ffffffff1690508060e01b82527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000016002846040518082805190602001908083835b60208310613b005780518252601f199092019160209182019101613ae1565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015613b3f573d6000803e3d6000fd5b5050506040513d6020811015613b5457600080fd5b505181613b5d57fe5b069f9e505050505050505050505050505050565b601354600160401b900463ffffffff1660009081526012602052604081208054604e600261010060018416150260001901909216919091040490613bb5908361542b565b60138054600163ffffffff600160401b808404821692909201811682026bffffffff000000000000000019909316929092179283905582048116600160601b909204161415613c295760138054600163ffffffff600160601b808404821692909201160263ffffffff60601b199091161790555b905090565b600082826020811015613c4057600080fd5b50356001600160e01b031916905063d505accf60e01b8114613c935760405162461bcd60e51b815260040180806020018281038252602e815260200180615e83602e913960400191505060405180910390fd5b6000808080808080613ca8896004818d6154c7565b60e0811015613cb657600080fd5b506001600160a01b038135811698506020820135169650604081013595506060810135945060ff608082013516935060a0810135925060c001359050338714613d305760405162461bcd60e51b815260040180806020018281038252603081526020018061566e6030913960400191505060405180910390fd5b6001600160a01b0386163014613d775760405162461bcd60e51b81526004018080602001828103825260258152602001806159116025913960400191505060405180910390fd5b8a8514613db55760405162461bcd60e51b815260040180806020018281038252602d815260200180615bf9602d913960400191505060405180910390fd5b8b6001600160a01b031663d505accf60e01b8888888888888860405160240180886001600160a01b03168152602001876001600160a01b031681526020018681526020018581526020018460ff168152602001838152602001828152602001975050505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518082805190602001908083835b60208310613e7f5780518252601f199092019160209182019101613e60565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613ee1576040519150601f19603f3d011682016040523d82523d6000602084013e613ee6565b606091505b505050505050505050505050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b60208310613f7c5780518252601f199092019160209182019101613f5d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613fde576040519150601f19603f3d011682016040523d82523d6000602084013e613fe3565b606091505b5091509150818015614011575080511580614011575080806020019051602081101561400e57600080fd5b50515b61404c5760405162461bcd60e51b815260040180806020018281038252603481526020018061563a6034913960400191505060405180910390fd5b505050505050565b6000806140618484613279565b9050806140725760019150506115a6565b600061407d82613438565b9050806000191415614094576001925050506115a6565b6000806000806000806140b960046000898152602001908152602001600020546115f8565b95509550955095509550955060006140da864361349590919063ffffffff16565b905060006140e882866134de565b90506140f761156c8286613520565b955082861061410b57829550439650614122565b61411f6141188287613520565b8890613579565b96505b8561413a5760009a50505050505050505050506115a6565b614145866001613495565b9550614155888888888888612e4e565b600460008b815260200190815260200160002081905550868960ff167fa35fe9a9e21cdbbc4774aa8a56e7b97ea9c06afc09ffb06af593d26951e350aa886040518082815260200191505060405180910390a35060019c9b505050505050505050505050565b8015614201576141fc600e8363ffffffff16815481106141d757fe5b6000918252602090912001546001600160a01b0316336001600160c01b038616614aa6565b6136a5565b63ffffffff821661428d576006546040805163cfc0b64160e01b81523360048201526000602482018190526001600160c01b0387166044830181905292516001600160a01b039094169363cfc0b6419392606480820193929182900301818588803b15801561426f57600080fd5b505af1158015614283573d6000803e3d6000fd5b50505050506136a5565b6000600e8363ffffffff16815481106142a257fe5b6000918252602090912001546006546001600160a01b0391821692506142d4918391166001600160c01b038716614cf8565b6006546040805163cfc0b64160e01b81523360048201526001600160a01b0384811660248301526001600160c01b03881660448301529151919092169163cfc0b64191606480830192600092919082900301818387803b15801561433757600080fd5b505af115801561434b573d6000803e3d6000fd5b5050505050505050565b6407ffffffff811660239190911c601f16600a0a0290565b600061437884614355565b9050600160c01b81106143bc5760405162461bcd60e51b815260040180806020018281038252602e8152602001806158b9602e913960400191505060405180910390fd5b65ffffffffffff821661440b5780156144065760405162461bcd60e51b815260040180806020018281038252603b815260200180615e48603b913960400191505060405180910390fd5b6144c8565b65ffffffffffff8216600114156144605764ffffffffff8516156144065760405162461bcd60e51b815260040180806020018281038252603781526020018061569e6037913960400191505060405180910390fd5b60ff65ffffffffffff831611801561448d575060095465ffffffffffff600160a01b909104811690831611155b6144c85760405162461bcd60e51b8152600401808060200182810382526028815260200180615b7e6028913960400191505060405180910390fd5b65ffffffffffff861661451657866145115760405162461bcd60e51b81526004018080602001828103825260418152602001806157ad6041913960600191505060405180910390fd5b6145bb565b60ff65ffffffffffff8716118015614543575060095465ffffffffffff600160a01b909104811690871611155b61457e5760405162461bcd60e51b815260040180806020018281038252602a8152602001806158e7602a913960400191505060405180910390fd5b86156145bb5760405162461bcd60e51b8152600401808060200182810382526042815260200180615b186042913960600191505060405180910390fd5b61434b88888888888888614e45565b6145d261540d565b6145da61540d565b63ffffffff96909616602095861b65ffff000000001617690100000000000000000060b785901c1617865250928401919091526001600160ff1b031660408301526001600160a01b0316606082015290565b60025460405163248f667760e01b81526000916001600160a01b03169063248f6677908490600401808260808083838a5b8381101561467557818101518382015260200161465d565b5050505090500191505060206040518083038186803b15801561469757600080fd5b505afa1580156146ab573d6000803e3d6000fd5b505050506040513d60208110156146c157600080fd5b505192915050565b6000806146d68484614ffd565b8551909150600090600019015b60008112614743578681815181106146f757fe5b6020026020010151915060008187600082121561471057fe5b6001911c81161490508061472d576147288484615029565b614737565b6147378385615029565b935050600019016146e3565b5050909414949350505050565b600081848411156147df5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156147a457818101518382015260200161478c565b50505050905090810190601f1680156147d15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836148365760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156147a457818101518382015260200161478c565b50600083858161342e57fe5b60008061484f6003614a79565b90925090506065810460006060851561491f57601354600160401b900463ffffffff166000908152601260209081526040918290208054835160026101006001841615026000190190921691909104601f81018490048402820184019094528381529290918301828280156149055780601f106148da57610100808354040283529160200191614905565b820191906000526020600020905b8154815290600101906020018083116148e857829003601f168201915b50505050509050604e81518161491757fe5b049150614924565b600091505b61010083830111156149675760405162461bcd60e51b8152600401808060200182810382526024815260200180615b5a6024913960400191505060405180910390fd5b811561499557604e820287019660208201905b8881101561499257815181526020918201910161497a565b50505b60005b83811015614a5c57600e546065870196803560001a916001820135916021810135916041820135916061013560e01c908110614a055760405162461bcd60e51b815260040180806020018281038252602a815260200180615aab602a913960400191505060405180910390fd5b6001600160a01b0360ff861615614a2557614a2283858789615046565b90505b60601b8d5260148d0191909152600060348d0181905260e09190911b60448d015260488c01525050604e9098019750600101614998565b50614a7087604e8585610100030302614a8d565b50505050505050565b602002600490810135602481019291013590565b808201915b828110156136a55760008152602001614a92565b6001600160a01b038316614ba45760408051600080825260208201909252339083906040518082805190602001908083835b60208310614af75780518252601f199092019160209182019101614ad8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614b59576040519150601f19603f3d011682016040523d82523d6000602084013e614b5e565b606091505b5050905080614b9e5760405162461bcd60e51b815260040180806020018281038252602a815260200180615bcf602a913960400191505060405180910390fd5b506136a5565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310614c215780518252601f199092019160209182019101614c02565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614c83576040519150601f19603f3d011682016040523d82523d6000602084013e614c88565b606091505b5091509150818015614cb6575080511580614cb65750808060200190516020811015614cb357600080fd5b50515b614cf15760405162461bcd60e51b815260040180806020018281038252602c8152602001806156d5602c913960400191505060405180910390fd5b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b178152925182516000946060949389169392918291908083835b60208310614d755780518252601f199092019160209182019101614d56565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614dd7576040519150601f19603f3d011682016040523d82523d6000602084013e614ddc565b606091505b5091509150818015614e0a575080511580614e0a5750808060200190516020811015614e0757600080fd5b50515b614cf15760405162461bcd60e51b815260040180806020018281038252602a815260200180615de5602a913960400191505060405180910390fd5b604080516bffffffffffffffffffffffff1960608a901b16602080830191909152603482018990526001600160d01b031960d089811b821660548501526001600160d81b031960d88a811b8216605a87015289901b16605f8501526001600160e01b031960e088901b16606485015285901b1660688301528251604e81840381018252606e9093018452601354600160601b900463ffffffff16600090815260129092529290208054600260001960018316156101000201909116049190910490614f10908361523f565b601354604080516020808252855181830152855160ff861694600160601b900463ffffffff16937fdd5c7c5ea02d3c5d1621513faa6de53d474ee6f111eda6352a63e3dfe8c401199388939092839283019185019080838360005b83811015614f83578181015183820152602001614f6b565b50505050905090810190601f168015614fb05780820380516001836020036101000a031916815260200191505b509250505060405180910390a360808160010110612d635760138054600163ffffffff600160601b808404821692909201160263ffffffff60601b19909116179055505050505050505050565b6000615007615472565b838152602081018390526001604082015261502181615389565b949350505050565b6000615033615490565b83815260208101839052615021816153c6565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156150a75760405162461bcd60e51b8152600401808060200182810382526029815260200180615eb16029913960400191505060405180910390fd5b604080517fafd642c6a37a2e6887dc4ad5142f84197828a904e53d3204ecb1100329231eaa6020808301919091527fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad828401527fff946cf82975b1a2b6e6d28c9a76a4b8d7a1fd0592b785cb92771933310f9ee7606083015260808083018990528351808403909101815260a09092019092528051910120600061514961140d565b82604051602001808061190160f01b81525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018286898960405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156151e2573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166152345760405162461bcd60e51b815260040180806020018281038252602b8152602001806159da602b913960400191505060405180910390fd5b979650505050505050565b8154600260018083161561010002038216048251808201602081106020841001600281146152e9576001811461530e578660005260208404602060002001600160028402018855602085068060200390508088018589016001836101000a0392508282511684540184556001840193506020820191505b808210156152d357815184556001840193506020820191506152b6565b815191036101000a908190040290915550614a70565b60028302826020036101000a846020036101000a602089015104020185018755614a70565b8660005260208404602060002001600160028402018855846020038088018589016001836101000a0392508282511660ff198a160184556020820191506001840193505b8082101561536f5781518455600184019350602082019150615352565b815191036101000a90819004029091555050505050505050565b6001546040516304b98e1d60e31b8152825160049091019081526000916001600160a01b0316906325cc70e890849080826060808383602061465d565b60008054604080516314d2f97b60e11b8152620100009092046001600160a01b0316916329a5f2f691859160040190819083908083838a818101518382015260200161465d565b60405180608001604052806004906020820280368337509192915050565b50805460018160011615610100020316600290046000825580601f10615451575061546f565b601f01602090049060005260206000209081019061546f91906154ae565b50565b60405180606001604052806003906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b5b808211156154c357600081556001016154af565b5090565b600080858511156154d6578182fd5b838611156154e2578182fd5b505082019391909203915056fe496e7374616e7457697468647261774d616e616765723a3a5f746f6b656e325553443a20544f4b454e5f444543494d414c535f4f564552464c4f574865726d657a3a3a5f636f6e73747275637443697263756974496e7075743a20494e56414c49445f464545494458434f4f5244494e41544f525f4c454e475448496e7374616e7457697468647261774d616e616765723a3a757064617465546f6b656e45786368616e67653a20494e56414c49445f41525241595f4c454e4754484865726d657a3a3a757064617465466f7267654c314c32426174636854696d656f75743a204d41585f464f52474554494d454f55545f4558434545444865726d657a3a3a666f72676542617463683a20494e56414c49445f50524f4f464865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4558434545445f4c494d49544865726d657a3a3a5f736166655472616e7366657246726f6d3a2045524332305f5452414e5346455246524f4d5f4641494c45444865726d657a3a3a5f7065726d69743a205045524d49545f4f574e45525f4d5553545f42455f5448455f53454e4445524865726d657a3a3a5f6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4d5553545f42455f305f49465f455849544865726d657a3a3a5f736166655472616e736665723a2045524332305f5452414e534645525f4641494c4544496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a204d41585f4e554d5f4255434b4554534865726d657a3a3a666f72676542617463683a2041554354494f4e5f44454e494544496e7374616e7457697468647261774d616e616765723a3a7570646174655769746864726177616c44656c61793a204558434545445f4d41585f5749544844524157414c5f44454c41594865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f4352454154455f4143434f554e545f574954485f4e4f5f424142594a55424865726d657a3a3a616464546f6b656e3a20414444524553535f305f494e56414c49444865726d657a3a3a757064617465566572696669657273205645524946494552535f414c52454144595f555044415445444865726d657a3a3a666f72676542617463683a20494e54454e414c5f54585f4e4f545f414c4c4f5745444865726d657a3a3a616464546f6b656e3a20544f4b454e5f4c4953545f46554c4c4865726d657a3a3a696e697469616c697a654865726d657a20414444524553535f305f4e4f545f56414c49444865726d657a3a3a5f6164644c315472616e73616374696f6e3a20414d4f554e545f4558434545445f4c494d49544865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f46524f4d4944584865726d657a3a3a5f7065726d69743a205350454e4445525f4d5553545f42455f544849534865726d657a3a3a6164644c315472616e73616374696f6e3a204d53475f56414c55455f4e4f545f455155414c5f304865726d657a3a3a77697468647261774d65726b6c6550726f6f663a20494e5354414e545f57495448445241575f5741535445445f464f525f544849535f5553445f52414e4745496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65644865726d657a48656c706572733a3a5f636865636b5369673a20494e56414c49445f5349474e41545552454865726d657a3a3a757064617465566572696669657273204f4e4c595f4445504c4f5945524865726d657a3a3a77697468647261774d65726b6c6550726f6f663a2057495448445241575f414c52454144595f444f4e45536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774865726d657a3a3a7769746864726177436972637569743a2057495448445241575f414c52454144595f444f4e454865726d657a3a3a5f6275696c644c31446174613a20544f4b454e5f4e4f545f524547495354455245444865726d657a3a3a7769746864726177436972637569743a20494e5354414e545f57495448445241575f5741535445445f464f525f544849535f5553445f52414e47454865726d657a3a3a5f6164644c315472616e73616374696f6e3a20424142594a55425f4d5553545f42455f305f49465f4e4f545f4352454154455f4143434f554e544865726d657a3a3a5f6275696c644c31446174613a204c315f54585f4f564552464c4f574865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f544f4944584865726d657a3a3a7769746864726177436972637569743a20494e56414c49445f5a4b5f50524f4f464865726d657a3a3a5f736166655472616e736665723a204554485f5452414e534645525f4641494c45444865726d657a3a3a5f7065726d69743a205045524d49545f414d4f554e545f444f45535f4e4f545f4d415443484865726d657a3a3a666f72676542617463683a204c314c3242415443485f52455155495245444865726d657a3a3a6164644c315472616e73616374696f6e3a20544f4b454e5f4e4f545f524547495354455245444865726d657a3a3a77697468647261774d65726b6c6550726f6f663a20534d545f50524f4f465f494e56414c4944496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a20524154455f424c4f434b535f4d5553545f42455f4d4f52455f5448414e5f304865726d657a3a3a616464546f6b656e3a20544f54414c5f535550504c595f5a45524f4865726d657a3a3a5f636f6e73747275637443697263756974496e7075743a204c325f54585f4f564552464c4f57496e7374616e7457697468647261774d616e616765723a3a6f6e6c79476f7665726e616e63653a204f4e4c595f474f5645524e414e43455f41444452455353496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a205749544844524157414c535f4d5553545f42455f4c4553535f5448414e5f4d41585749544844524157414c534865726d657a3a3a5f73616665417070726f76653a2045524332305f415050524f56455f4641494c45444865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f45524332305f444f45535f4e4f545f4d415443484865726d657a3a3a5f6164644c315472616e73616374696f6e3a20414d4f554e545f4d5553545f42455f305f49465f4e4f545f5452414e534645524865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204e4f545f56414c49445f43414c4c4865726d657a48656c706572733a3a5f636865636b5369673a20494e56414c49445f535f56414c55454865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4554485f444f45535f4e4f545f4d41544348a2646970667358221220e5fc23964ebee4391cb37d0cad23ee3495099d877a43d55d3932956e0ec65a9c64736f6c634300060c0033", + "deployedBytecode": "0x6080604052600436106102e35760003560e01c8063864eb16411610190578063c473af33116100dc578063d486645c11610095578063e62f6b921161006f578063e62f6b921461106f578063ef4a5c4a14611084578063f1f2fcab1461035e578063f84f92ee146110b7576102e3565b8063d486645c14610eb3578063d9d4ca4414610ee3578063dc3e718e14610fca576102e3565b8063c473af3314610d34578063c727305314610d49578063cbd7b5fb14610df9578063ccd226a714610e26578063ce5ec65a14610e6e578063d0f32e6714610e9e576102e3565b80639ead722211610149578063a7ab696111610123578063a7ab696114610c47578063abe3219c14610c5c578063ac300ec914610c71578063bded9bb814610d1f576102e3565b80639ead722214610bf35780639f34e9a314610c1d578063a327583814610c32576102e3565b8063864eb16414610aec57806395a09f2a14610b01578063960207c014610b2c5780639ce2ad4214610b415780639e00d7ea14610bae5780639e4e731814610bde576102e3565b80633408e4701161024f57806344e0b2ce1161020857806370c2f1c0116101e257806370c2f1c014610a2257806379a135e314610aad5780637ba3a5e014610ac257806384ef9ed414610ad7576102e3565b806344e0b2ce14610729578063599897e31461073e5780636e7e1365146108d0576102e3565b80633408e470146105ca5780633644e515146105df578063375110aa146105f4578063383302001461064a5780633ee641ea1461069c5780633f267155146106cc576102e3565b80630ee8e52b116102a15780630ee8e52b146104015780631300aff01461042f5780631a748c2d146104445780631b0a8223146105765780632bd836261461058b578063314e5eda146105a0576102e3565b80624aca6e146102e8578063013f78521461032d57806304622c2e1461035e578063061d09641461037357806307feef6e1461039d5780630dd94b96146103b2575b600080fd5b3480156102f457600080fd5b5061031b6004803603602081101561030b57600080fd5b50356001600160a01b03166110f5565b60408051918252519081900360200190f35b34801561033957600080fd5b50610342611107565b604080516001600160a01b039092168252519081900360200190f35b34801561036a57600080fd5b5061031b611116565b34801561037f57600080fd5b5061031b6004803603602081101561039657600080fd5b503561113a565b3480156103a957600080fd5b5061031b61114c565b3480156103be57600080fd5b506103e5600480360360208110156103d557600080fd5b50356001600160a01b0316611152565b604080516001600160401b039092168252519081900360200190f35b34801561040d57600080fd5b5061041661116d565b6040805163ffffffff9092168252519081900360200190f35b34801561043b57600080fd5b5061031b611180565b34801561045057600080fd5b506105746004803603604081101561046757600080fd5b810190602081018135600160201b81111561048157600080fd5b82018360208201111561049357600080fd5b803590602001918460208302840111600160201b831117156104b457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b81111561050357600080fd5b82018360208201111561051557600080fd5b803590602001918460208302840111600160201b8311171561053657600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295506111a4945050505050565b005b34801561058257600080fd5b50610342611367565b34801561059757600080fd5b50610342611376565b3480156105ac57600080fd5b50610574600480360360208110156105c357600080fd5b5035611385565b3480156105d657600080fd5b5061031b611409565b3480156105eb57600080fd5b5061031b61140d565b34801561060057600080fd5b506106366004803603604081101561061757600080fd5b5080356001600160a01b031690602001356001600160c01b03166114cb565b604080519115158252519081900360200190f35b34801561065657600080fd5b506106746004803603602081101561066d57600080fd5b50356115ac565b604080516001600160a01b039094168452602084019290925282820152519081900360600190f35b3480156106a857600080fd5b5061031b600480360360208110156106bf57600080fd5b503563ffffffff166115e6565b3480156106d857600080fd5b506106f6600480360360208110156106ef57600080fd5b50356115f8565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b34801561073557600080fd5b5061041661162d565b34801561074a57600080fd5b5061057460048036036101a081101561076257600080fd5b810190602081018135600160201b81111561077c57600080fd5b82018360208201111561078e57600080fd5b803590602001918460208302840111600160201b831117156107af57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050600160201b8111156107fe57600080fd5b82018360208201111561081057600080fd5b803590602001918460208302840111600160201b8311171561083157600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550506001600160a01b03833581169450602084013581169360408101358216935060ff606082013516925060808101359160a082013581169160c081013582169160e08201358116916101008101358216916001600160401b036101208301351691610140013516611640565b3480156108dc57600080fd5b5061057460048036036102008110156108f457600080fd5b65ffffffffffff8235169160208101359160408201359190810190608081016060820135600160201b81111561092957600080fd5b82018360208201111561093b57600080fd5b803590602001918460018302840111600160201b8311171561095c57600080fd5b919390929091602081019035600160201b81111561097957600080fd5b82018360208201111561098b57600080fd5b803590602001918460018302840111600160201b831117156109ac57600080fd5b919390929091602081019035600160201b8111156109c957600080fd5b8201836020820111156109db57600080fd5b803590602001918460018302840111600160201b831117156109fc57600080fd5b919350915060ff81351690602081013515159060408101906080810190610100016118de565b348015610a2e57600080fd5b5061057460048036036040811015610a4557600080fd5b6001600160a01b038235169190810190604081016020820135600160201b811115610a6f57600080fd5b820183602082011115610a8157600080fd5b803590602001918460018302840111600160201b83111715610aa257600080fd5b509092509050611dc8565b348015610ab957600080fd5b50610342612051565b348015610ace57600080fd5b5061031b612060565b348015610ae357600080fd5b506103e5612066565b348015610af857600080fd5b50610342612075565b348015610b0d57600080fd5b50610b16612084565b6040805160ff9092168252519081900360200190f35b348015610b3857600080fd5b50610574612089565b348015610b4d57600080fd5b5061057460048036036101a0811015610b6557600080fd5b506040810160c0820163ffffffff6101008401358116906001600160c01b0361012086013516906101408601351665ffffffffffff6101608701351661018087013515156122a8565b348015610bba57600080fd5b5061031b60048036036020811015610bd157600080fd5b503563ffffffff1661267b565b348015610bea57600080fd5b5061031b61268d565b348015610bff57600080fd5b5061034260048036036020811015610c1657600080fd5b50356126b1565b348015610c2957600080fd5b5061031b6126d8565b348015610c3e57600080fd5b50610b166126de565b348015610c5357600080fd5b506103e56126ee565b348015610c6857600080fd5b50610574612704565b348015610c7d57600080fd5b5061057460048036036020811015610c9457600080fd5b810190602081018135600160201b811115610cae57600080fd5b820183602082011115610cc057600080fd5b803590602001918460208302840111600160201b83111715610ce157600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092955061283e945050505050565b348015610d2b57600080fd5b5061031b612a2e565b348015610d4057600080fd5b5061031b612a34565b610574600480360360e0811015610d5f57600080fd5b81359165ffffffffffff602082013581169264ffffffffff604084013581169360608101359091169263ffffffff6080830135169260a0830135909116919081019060e0810160c0820135600160201b811115610dbb57600080fd5b820183602082011115610dcd57600080fd5b803590602001918460018302840111600160201b83111715610dee57600080fd5b509092509050612a58565b348015610e0557600080fd5b5061057460048036036020811015610e1c57600080fd5b503560ff16612d6e565b348015610e3257600080fd5b5061031b600480360360c0811015610e4957600080fd5b5080359060208101359060408101359060608101359060808101359060a00135612e4e565b348015610e7a57600080fd5b5061031b60048036036020811015610e9157600080fd5b503563ffffffff16612e7b565b348015610eaa57600080fd5b50610416612e8d565b348015610ebf57600080fd5b50610ec8612ea0565b6040805165ffffffffffff9092168252519081900360200190f35b348015610eef57600080fd5b50610574600480360360e0811015610f0657600080fd5b63ffffffff82358116926001600160c01b0360208201351692604082013592606083013516919081019060a081016080820135600160201b811115610f4a57600080fd5b820183602082011115610f5c57600080fd5b803590602001918460208302840111600160201b83111715610f7d57600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295505065ffffffffffff83351693505050602001351515612eb5565b348015610fd657600080fd5b50610ffa60048036036020811015610fed57600080fd5b503563ffffffff166130a5565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561103457818101518382015260200161101c565b50505050905090810190601f1680156110615780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561107b57600080fd5b5061031b613140565b34801561109057600080fd5b50610574600480360360208110156110a757600080fd5b50356001600160401b0316613164565b3480156110c357600080fd5b50610636600480360360408110156110da57600080fd5b50803563ffffffff16906020013565ffffffffffff16613259565b600f6020526000908152604090205481565b6005546001600160a01b031681565b7fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad81565b60046020526000908152604090205481565b60035481565b6007602052600090815260409020546001600160401b031681565b601354600160601b900463ffffffff1681565b7fff946cf82975b1a2b6e6d28c9a76a4b8d7a1fd0592b785cb92771933310f9ee781565b6005546001600160a01b031633146111ed5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b805182511461122d5760405162461bcd60e51b815260040180806020018281038252604181526020018061556b6041913960600191505060405180910390fd5b60005b82518110156112a75781818151811061124557fe5b60200260200101516007600085848151811061125d57fe5b6020908102919091018101516001600160a01b03168252810191909152604001600020805467ffffffffffffffff19166001600160401b0392909216919091179055600101611230565b507f10ff643ebeca3e33002e61b76fa85e7e10091e30afa39295f91af9838b3033b38282604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b8381101561130f5781810151838201526020016112f7565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561134e578181015183820152602001611336565b5050505090500194505050505060405180910390a15050565b6006546001600160a01b031681565b6011546001600160a01b031681565b6005546001600160a01b031633146113ce5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b60108190556040805182815290517fd1c873cd16013f0dc5f37992c0d12794389698512895ec036a568e393b46e3c19181900360200190a150565b4690565b60007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f7fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc661147a611409565b3060405160200180868152602001858152602001848152602001838152602001826001600160a01b031681526020019550505050505060405160208183030381529060405280519060200120905090565b6000806114d88484613279565b9050806114e95760019150506115a6565b60006114f482613438565b905080600019141561150b576001925050506115a6565b600080600080600061152f60046000888152602001908152602001600020546115f8565b9550955095509550955050600061154f864361349590919063ffffffff16565b9050600061155d82866134de565b905061157361156c8286613520565b8790613579565b955082861115611581578295505b8561159857600099505050505050505050506115a6565b600199505050505050505050505b92915050565b600881815481106115b957fe5b60009182526020909120600390910201805460018201546002909201546001600160a01b03909116925083565b600b6020526000908152604090205481565b6001600160601b0381169163ffffffff606083901c811692608081901c82169260a082901c83169260c083901c169160e01c90565b600954600160d01b900463ffffffff1681565b600054610100900460ff168061165957506116596135d3565b80611667575060005460ff16155b6116a25760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff161580156116cd576000805460ff1961ff0019909116610100171660011790555b6001600160a01b038b16158015906116ed57506001600160a01b03821615155b6117285760405162461bcd60e51b815260040180806020018281038252602c81526020018061588d602c913960400191505060405180910390fd5b6117328e8e6135d9565b8b600960006101000a8154816001600160a01b0302191690836001600160a01b031602179055508a601160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555089601460006101000a8154816001600160a01b0302191690836001600160a01b0316021790555088601360106101000a81548160ff021916908360ff1602179055508760108190555060ff600960146101000a81548165ffffffffffff021916908365ffffffffffff16021790555060016013600c6101000a81548163ffffffff021916908363ffffffff160217905550600e60009080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055506118668787876136aa565b6118718484846137a0565b6040805160ff8b168152602081018a90526001600160401b0385168183015290517fc5272ad4c8d9f2e9af2f9555c11ead049be22b6e45c16975adc82371b7cd10409181900360600190a180156118ce576000805461ff00191690555b5050505050505050505050505050565b33321461191c5760405162461bcd60e51b815260040180806020018281038252602a815260200180615842602a913960400191505060405180910390fd5b6011546040805163041d8fb560e51b815233600482015243602482015290516001600160a01b03909216916383b1f6a091604480820192602092909190829003018186803b15801561196d57600080fd5b505afa158015611981573d6000803e3d6000fd5b505050506040513d602081101561199757600080fd5b505115156001146119d95760405162461bcd60e51b81526004018080602001828103825260228152602001806157416022913960400191505060405180910390fd5b83611a3557601354600160801b810460ff166001600160401b0391821601164310611a355760405162461bcd60e51b8152600401808060200182810382526026815260200180615c266026913960400191505060405180910390fd5b6000611a448f8f8f888a613895565b905060088660ff1681548110611a5657fe5b60009182526020918290206003909102015460408051928301815283835280516343753b4d60e01b81526001600160a01b03909216926343753b4d9288928892889290916004909101908190869080828437600083820152601f01601f1916909101905084608080828437600083820152601f01601f1916909101905083604080828437600081840152601f19601f82011690508083019250505082600160200280838360005b83811015611b15578181015183820152602001611afd565b5050505090500194505050505060206040518083038186803b158015611b3a57600080fd5b505afa158015611b4e573d6000803e3d6000fd5b505050506040513d6020811015611b6457600080fd5b5051611ba15760405162461bcd60e51b81526004018080602001828103825260218152602001806155e86021913960400191505060405180910390fd5b6009601a81819054906101000a900463ffffffff168092919060010191906101000a81548163ffffffff021916908363ffffffff160217905550508e600960146101000a81548165ffffffffffff021916908365ffffffffffff1602179055508d600a60006009601a9054906101000a900463ffffffff1663ffffffff1663ffffffff168152602001908152602001600020819055508c600b60006009601a9054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020019081526020016000208190555060028a8a6040518083838082843760405192019450602093509091505080830381855afa158015611ca2573d6000803e3d6000fd5b5050506040513d6020811015611cb757600080fd5b5051600954600160d01b900463ffffffff166000908152600c60205260408120919091558515611d08576013805467ffffffffffffffff1916436001600160401b0316179055611d05613b71565b90505b601154604080516309cb4a2f60e31b815233600482015290516001600160a01b0390921691634e5a51789160248082019260009290919082900301818387803b158015611d5457600080fd5b505af1158015611d68573d6000803e3d6000fd5b50506009546040805161ffff861681529051600160d01b90920463ffffffff1693507fe00040c8a3b0bf905636c26924e90520eafc5003324138236fddee2d3458861892506020908290030190a250505050505050505050505050505050565b6000836001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611e0357600080fd5b505afa158015611e17573d6000803e3d6000fd5b505050506040513d6020811015611e2d57600080fd5b505111611e6b5760405162461bcd60e51b8152600401808060200182810382526023815260200180615cf86023913960400191505060405180910390fd5b600e54600160201b8110611eb05760405162461bcd60e51b815260040180806020018281038252602181526020018061586c6021913960400191505060405180910390fd5b6001600160a01b038416611ef55760405162461bcd60e51b81526004018080602001828103825260238152602001806157ee6023913960400191505060405180910390fd5b6001600160a01b0384166000908152600f602052604090205415611f60576040805162461bcd60e51b815260206004820152601f60248201527f4865726d657a3a3a616464546f6b656e3a20414c52454144595f414444454400604482015290519081900360640190fd5b6005546001600160a01b03163314611fb6578115611f9357601454601054611f93916001600160a01b0316908585613c2e565b601454600554601054611fb6926001600160a01b03908116923392911690613ef7565b600e8054600181019091557fbb7b4a454dc3493923482f07822329ed19e8244eff582cc204f8554c3620c3fd0180546001600160a01b0319166001600160a01b0386169081179091556000818152600f6020908152604091829020849055815163ffffffff8516815291517fcb73d161edb7cd4fb1d92fedfd2555384fd997fd44ab507656f8c81e15747dde9281900390910190a250505050565b6014546001600160a01b031681565b60085490565b6013546001600160401b031681565b6009546001600160a01b031681565b60f081565b3373b6d3f1056c015962fa66a4020e50522b58292d1e146120db5760405162461bcd60e51b8152600401808060200182810382526025815260200180615a056025913960400191505060405180910390fd5b60086000815481106120e957fe5b9060005260206000209060030201600101546101581461213a5760405162461bcd60e51b81526004018080602001828103825260318152602001806158116031913960400191505060405180910390fd5b6040518060600160405280733daa0b2a994b1bc60db9e312ad0a8d87a1bb16d26001600160a01b0316815260200161019081526020016020815250600860008154811061218357fe5b906000526020600020906003020160008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201559050506040518060600160405280731dc4b451dfcd0e848881ede8c7a99978f00b13426001600160a01b0316815260200161080081526020016020815250600860018154811061221e57fe5b60009182526020808320845160039093020180546001600160a01b039093166001600160a01b031993841617815590840151600182015560409384015160029091015560098054909116734464a1e499cf5443541da6728871af1d5c4920ca17905590517fd5303fa2e7ece2a0fe77fbba1df5bb224b461198dd7bfd7fe0071f964c86c6739190a1565b801561231a576122df600e8663ffffffff16815481106122c457fe5b6000918252602090912001546001600160a01b031685614054565b61231a5760405162461bcd60e51b8152600401808060200182810382526043815260200180615ad56043913960600191505060405180910390fd5b63ffffffff83166000908152600d6020908152604080832065ffffffffffff8616845290915290205460ff16156123825760405162461bcd60e51b815260040180806020018281038252602e815260200180615a7d602e913960400191505060405180910390fd5b63ffffffff83166000908152600b602090815260408083205481518084018290523360601b818401526001600160e01b031960e08b901b16605482015267ffffffffffffffff1989841b1660588201526001600160d01b031960d088901b1660708201528251605681830301815260769091019283905280519194937f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000019360029390918291908401908083835b6020831061244e5780518252601f19909201916020918201910161242f565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa15801561248d573d6000803e3d6000fd5b5050506040513d60208110156124a257600080fd5b5051816124ab57fe5b600954604080516020810182529390920680845282516343753b4d60e01b81529094506001600160a01b03909116926343753b4d928e928e928e929091600401908190869080828437600083820152601f01601f1916909101905084608080828437600083820152601f01601f1916909101905083604080828437600081840152601f19601f82011690508083019250505082600160200280838360005b83811015612561578181015183820152602001612549565b5050505090500194505050505060206040518083038186803b15801561258657600080fd5b505afa15801561259a573d6000803e3d6000fd5b505050506040513d60208110156125b057600080fd5b505115156001146125f25760405162461bcd60e51b8152600401808060200182810382526029815260200180615ba66029913960400191505060405180910390fd5b63ffffffff85166000908152600d6020908152604080832065ffffffffffff881684529091529020805460ff191660011790556126308688856141bb565b8215158563ffffffff168565ffffffffffff167f69177d798b38e27bcc4e0338307e4f1490e12d1006729d0e6e9cc82a8732f41560405160405180910390a450505050505050505050565b600a6020526000908152604090205481565b7fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc681565b600e81815481106126be57fe5b6000918252602090912001546001600160a01b0316905081565b600e5490565b601354600160801b900460ff1681565b600554600160a01b90046001600160401b031681565b6005546001600160a01b0316331461274d5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b600160038190555061276d6001600160601b036000806001600080612e4e565b6000808052600460208190527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec9290925560065460055460408051630e670af560e01b8152600160a01b9092046001600160401b03169482019490945292516001600160a01b0390911692630e670af592602480830193919282900301818387803b1580156127fb57600080fd5b505af115801561280f573d6000803e3d6000fd5b50506040517f0410e6ef2bd89ecf5b2dc2f62157f9863e09e89cb7c7f1abb7d4ec43a6019d1e925060009150a1565b6005546001600160a01b031633146128875760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b805160058111156128c95760405162461bcd60e51b81526004018080602001828103825260408152602001806157016040913960400191505060405180910390fd5b600381905560005b818110156129b45760008060008060006128fd8887815181106128f057fe5b60200260200101516115f8565b9550955095509550509450808411156129475760405162461bcd60e51b815260040180806020018281038252605d815260200180615d88605d913960600191505060405180910390fd5b600083116129865760405162461bcd60e51b8152600401808060200182810382526050815260200180615ca86050913960600191505060405180910390fd5b612994854386868686612e4e565b6000878152600460205260409020555050600190930192506128d1915050565b507fd4904145d7eae889c5493798579680417459783db0fa67398bea50e56859075f826040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015612a175781810151838201526020016129ff565b505050509050019250505060405180910390a15050565b60105481565b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f81565b600e5463ffffffff851610612a9e5760405162461bcd60e51b815260040180806020018281038252602e815260200180615c4c602e913960400191505060405180910390fd5b6000612aa987614355565b9050600160801b8110612aed5760405162461bcd60e51b81526004018080602001828103825260318152602001806156096031913960400191505060405180910390fd5b8015612d545763ffffffff8516612b4157348114612b3c5760405162461bcd60e51b8152600401808060200182810382526037815260200180615eda6037913960400191505060405180910390fd5b612d54565b3415612b7e5760405162461bcd60e51b815260040180806020018281038252602f815260200180615936602f913960400191505060405180910390fd5b8115612bb757612bb7600e8663ffffffff1681548110612b9a57fe5b6000918252602090912001546001600160a01b0316828585613c2e565b6000600e8663ffffffff1681548110612bcc57fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015612c1b57600080fd5b505afa158015612c2f573d6000803e3d6000fd5b505050506040513d6020811015612c4557600080fd5b5051600e8054919250612c7f9163ffffffff8916908110612c6257fe5b6000918252602090912001546001600160a01b0316333085613ef7565b6000600e8763ffffffff1681548110612c9457fe5b60009182526020918290200154604080516370a0823160e01b815230600482015290516001600160a01b03909216926370a0823192602480840193829003018186803b158015612ce357600080fd5b505afa158015612cf7573d6000803e3d6000fd5b505050506040513d6020811015612d0d57600080fd5b505190508181038314612d515760405162461bcd60e51b8152600401808060200182810382526039815260200180615e0f6039913960400191505060405180910390fd5b50505b612d63338a8a8a8a8a8a61436d565b505050505050505050565b6005546001600160a01b03163314612db75760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b60f060ff82161115612dfa5760405162461bcd60e51b815260040180806020018281038252603c8152602001806155ac603c913960400191505060405180910390fd5b6013805460ff8316600160801b810260ff60801b199092169190911790915560408051918252517fff6221781ac525b04585dbb55cd2ebd2a92c828ca3e42b23813a1137ac9744319181900360200190a150565b600060e082901b60c084901b60a086901b608088901b60608a901b8b171717171790509695505050505050565b600c6020526000908152604090205481565b601354600160401b900463ffffffff1681565b600954600160a01b900465ffffffffffff1681565b8015612f2757612eec600e8863ffffffff1681548110612ed157fe5b6000918252602090912001546001600160a01b031687614054565b612f275760405162461bcd60e51b81526004018080602001828103825260478152602001806159656047913960600191505060405180910390fd5b612f2f61540d565b612f46886000896001600160c01b031689336145ca565b90506000612f538261462c565b63ffffffff87166000908152600b6020908152604080832054600d835281842065ffffffffffff8a168552909252909120549192509060ff1615612fc85760405162461bcd60e51b8152600401808060200182810382526032815260200180615a2a6032913960400191505060405180910390fd5b612fdc81878765ffffffffffff16856146c9565b151560011461301c5760405162461bcd60e51b815260040180806020018281038252602e815260200180615c7a602e913960400191505060405180910390fd5b63ffffffff87166000908152600d6020908152604080832065ffffffffffff891684529091529020805460ff1916600117905561305a898b866141bb565b8315158763ffffffff168665ffffffffffff167f69177d798b38e27bcc4e0338307e4f1490e12d1006729d0e6e9cc82a8732f41560405160405180910390a450505050505050505050565b60126020908152600091825260409182902080548351601f6002600019610100600186161502019093169290920491820184900484028101840190945280845290918301828280156131385780601f1061310d57610100808354040283529160200191613138565b820191906000526020600020905b81548152906001019060200180831161311b57829003601f168201915b505050505081565b7fafd642c6a37a2e6887dc4ad5142f84197828a904e53d3204ecb1100329231eaa81565b6005546001600160a01b031633146131ad5760405162461bcd60e51b815260040180806020018281038252603f815260200180615d49603f913960400191505060405180910390fd5b62127500816001600160401b031611156131f85760405162461bcd60e51b815260040180806020018281038252604a815260200180615763604a913960600191505060405180910390fd5b600580546001600160401b038316600160a01b810267ffffffffffffffff60a01b199092169190911790915560408051918252517f9db302c4547a21fb20a3a794e5f63ee87eb6e4afc3325ebdadba2d1fb4a907379181900360200190a150565b600d60209081526000928352604080842090915290825290205460ff1681565b6001600160a01b0382166000908152600760205260408120546001600160401b03166132a7575060006115a6565b6001600160a01b0383166000818152600760205260408120546402540be4006001600160401b039091166001600160c01b0386160204916132ea575060126133dd565b60408051600481526024810182526020810180516001600160e01b031663313ce56760e01b178152915181516000936060936001600160a01b038b16939092909182918083835b602083106133505780518252601f199092019160209182019101613331565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855afa9150503d80600081146133b0576040519150601f19603f3d011682016040523d82523d6000602084013e6133b5565b606091505b509150915081156133da578080602001905160208110156133d557600080fd5b505192505b50505b604d8160ff161061341f5760405162461bcd60e51b815260040180806020018281038252603b8152602001806154f0603b913960400191505060405180910390fd5b8060ff16600a0a828161342e57fe5b0495945050505050565b6000805b600354811215613489576000818152600460205260409020546001600160601b031680841115806134735750806001600160601b03145b1561348057509050613490565b5060010161343c565b5060001990505b919050565b60006134d783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250614750565b9392505050565b60006134d783836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506147e7565b60008261352f575060006115a6565b8282028284828161353c57fe5b04146134d75760405162461bcd60e51b8152600401808060200182810382526021815260200180615a5c6021913960400191505060405180910390fd5b6000828201838110156134d7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b303b1590565b60005b82518110156136a557600860405180606001604052808584815181106135fe57fe5b60200260200101516001600160a01b0316815260200160088086868151811061362357fe5b6020026020010151901b901c815260200160f885858151811061364257fe5b60209081029190910181015190911c909152825460018082018555600094855293829020835160039092020180546001600160a01b0319166001600160a01b039092169190911781559082015181840155604090910151600290910155016135dc565b505050565b600054610100900460ff16806136c357506136c36135d3565b806136d1575060005460ff16155b61370c5760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff16158015613737576000805460ff1961ff0019909116610100171660011790555b600080546001600160a01b03808716620100000262010000600160b01b031990921691909117909155600180548583166001600160a01b0319918216179091556002805492851692909116919091179055801561379a576000805461ff00191690555b50505050565b600054610100900460ff16806137b957506137b96135d3565b806137c7575060005460ff16155b6138025760405162461bcd60e51b815260040180806020018281038252602e8152602001806159ac602e913960400191505060405180910390fd5b600054610100900460ff1615801561382d576000805460ff1961ff0019909116610100171660011790555b600580546001600160a01b03199081166001600160a01b038781169190911767ffffffffffffffff60a01b1916600160a01b6001600160401b038816021790925560068054909116918416919091179055801561379a576000805461ff001916905550505050565b600954600160d01b810463ffffffff166000908152600a60205260408120546008805492939192600160a01b90920465ffffffffffff16918491829182919060ff89169081106138e157fe5b9060005260206000209060030201600101546008808960ff168154811061390457fe5b9060005260206000209060030201600201548161391d57fe5b0460020260050160010102905060006008808960ff168154811061393d57fe5b9060005260206000209060030201600201548161395657fe5b60408051929091048102848101808401614eb201909252614e72909101825260d087811b60208401528e901b6026830152602c8201889052604c82018d9052606c82018c90529150608c81016139ac818c614842565b614e00016139ba6004614a79565b9096509450838511156139fe5760405162461bcd60e51b815260040180806020018281038252602e815260200180615d1b602e913960400191505060405180910390fd5b848682378401613a1081868603614a8d565b84840301613a1e6005614a79565b909650945082851115613a625760405162461bcd60e51b815260040180806020018281038252604081526020018061552b6040913960400191505060405180910390fd5b848682378401613a7481868503614a8d565b848303810190504660f01b815260028101905060006009601a9054906101000a900463ffffffff1660010163ffffffff1690508060e01b82527f30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f00000016002846040518082805190602001908083835b60208310613b005780518252601f199092019160209182019101613ae1565b51815160209384036101000a60001901801990921691161790526040519190930194509192505080830381855afa158015613b3f573d6000803e3d6000fd5b5050506040513d6020811015613b5457600080fd5b505181613b5d57fe5b069f9e505050505050505050505050505050565b601354600160401b900463ffffffff1660009081526012602052604081208054604e600261010060018416150260001901909216919091040490613bb5908361542b565b60138054600163ffffffff600160401b808404821692909201811682026bffffffff000000000000000019909316929092179283905582048116600160601b909204161415613c295760138054600163ffffffff600160601b808404821692909201160263ffffffff60601b199091161790555b905090565b600082826020811015613c4057600080fd5b50356001600160e01b031916905063d505accf60e01b8114613c935760405162461bcd60e51b815260040180806020018281038252602e815260200180615e83602e913960400191505060405180910390fd5b6000808080808080613ca8896004818d6154c7565b60e0811015613cb657600080fd5b506001600160a01b038135811698506020820135169650604081013595506060810135945060ff608082013516935060a0810135925060c001359050338714613d305760405162461bcd60e51b815260040180806020018281038252603081526020018061566e6030913960400191505060405180910390fd5b6001600160a01b0386163014613d775760405162461bcd60e51b81526004018080602001828103825260258152602001806159116025913960400191505060405180910390fd5b8a8514613db55760405162461bcd60e51b815260040180806020018281038252602d815260200180615bf9602d913960400191505060405180910390fd5b8b6001600160a01b031663d505accf60e01b8888888888888860405160240180886001600160a01b03168152602001876001600160a01b031681526020018681526020018581526020018460ff168152602001838152602001828152602001975050505050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518082805190602001908083835b60208310613e7f5780518252601f199092019160209182019101613e60565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613ee1576040519150601f19603f3d011682016040523d82523d6000602084013e613ee6565b606091505b505050505050505050505050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251600094606094938a169392918291908083835b60208310613f7c5780518252601f199092019160209182019101613f5d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613fde576040519150601f19603f3d011682016040523d82523d6000602084013e613fe3565b606091505b5091509150818015614011575080511580614011575080806020019051602081101561400e57600080fd5b50515b61404c5760405162461bcd60e51b815260040180806020018281038252603481526020018061563a6034913960400191505060405180910390fd5b505050505050565b6000806140618484613279565b9050806140725760019150506115a6565b600061407d82613438565b9050806000191415614094576001925050506115a6565b6000806000806000806140b960046000898152602001908152602001600020546115f8565b95509550955095509550955060006140da864361349590919063ffffffff16565b905060006140e882866134de565b90506140f761156c8286613520565b955082861061410b57829550439650614122565b61411f6141188287613520565b8890613579565b96505b8561413a5760009a50505050505050505050506115a6565b614145866001613495565b9550614155888888888888612e4e565b600460008b815260200190815260200160002081905550868960ff167fa35fe9a9e21cdbbc4774aa8a56e7b97ea9c06afc09ffb06af593d26951e350aa886040518082815260200191505060405180910390a35060019c9b505050505050505050505050565b8015614201576141fc600e8363ffffffff16815481106141d757fe5b6000918252602090912001546001600160a01b0316336001600160c01b038616614aa6565b6136a5565b63ffffffff821661428d576006546040805163cfc0b64160e01b81523360048201526000602482018190526001600160c01b0387166044830181905292516001600160a01b039094169363cfc0b6419392606480820193929182900301818588803b15801561426f57600080fd5b505af1158015614283573d6000803e3d6000fd5b50505050506136a5565b6000600e8363ffffffff16815481106142a257fe5b6000918252602090912001546006546001600160a01b0391821692506142d4918391166001600160c01b038716614cf8565b6006546040805163cfc0b64160e01b81523360048201526001600160a01b0384811660248301526001600160c01b03881660448301529151919092169163cfc0b64191606480830192600092919082900301818387803b15801561433757600080fd5b505af115801561434b573d6000803e3d6000fd5b5050505050505050565b6407ffffffff811660239190911c601f16600a0a0290565b600061437884614355565b9050600160c01b81106143bc5760405162461bcd60e51b815260040180806020018281038252602e8152602001806158b9602e913960400191505060405180910390fd5b65ffffffffffff821661440b5780156144065760405162461bcd60e51b815260040180806020018281038252603b815260200180615e48603b913960400191505060405180910390fd5b6144c8565b65ffffffffffff8216600114156144605764ffffffffff8516156144065760405162461bcd60e51b815260040180806020018281038252603781526020018061569e6037913960400191505060405180910390fd5b60ff65ffffffffffff831611801561448d575060095465ffffffffffff600160a01b909104811690831611155b6144c85760405162461bcd60e51b8152600401808060200182810382526028815260200180615b7e6028913960400191505060405180910390fd5b65ffffffffffff861661451657866145115760405162461bcd60e51b81526004018080602001828103825260418152602001806157ad6041913960600191505060405180910390fd5b6145bb565b60ff65ffffffffffff8716118015614543575060095465ffffffffffff600160a01b909104811690871611155b61457e5760405162461bcd60e51b815260040180806020018281038252602a8152602001806158e7602a913960400191505060405180910390fd5b86156145bb5760405162461bcd60e51b8152600401808060200182810382526042815260200180615b186042913960600191505060405180910390fd5b61434b88888888888888614e45565b6145d261540d565b6145da61540d565b63ffffffff96909616602095861b65ffff000000001617690100000000000000000060b785901c1617865250928401919091526001600160ff1b031660408301526001600160a01b0316606082015290565b60025460405163248f667760e01b81526000916001600160a01b03169063248f6677908490600401808260808083838a5b8381101561467557818101518382015260200161465d565b5050505090500191505060206040518083038186803b15801561469757600080fd5b505afa1580156146ab573d6000803e3d6000fd5b505050506040513d60208110156146c157600080fd5b505192915050565b6000806146d68484614ffd565b8551909150600090600019015b60008112614743578681815181106146f757fe5b6020026020010151915060008187600082121561471057fe5b6001911c81161490508061472d576147288484615029565b614737565b6147378385615029565b935050600019016146e3565b5050909414949350505050565b600081848411156147df5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156147a457818101518382015260200161478c565b50505050905090810190601f1680156147d15780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600081836148365760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156147a457818101518382015260200161478c565b50600083858161342e57fe5b60008061484f6003614a79565b90925090506065810460006060851561491f57601354600160401b900463ffffffff166000908152601260209081526040918290208054835160026101006001841615026000190190921691909104601f81018490048402820184019094528381529290918301828280156149055780601f106148da57610100808354040283529160200191614905565b820191906000526020600020905b8154815290600101906020018083116148e857829003601f168201915b50505050509050604e81518161491757fe5b049150614924565b600091505b61010083830111156149675760405162461bcd60e51b8152600401808060200182810382526024815260200180615b5a6024913960400191505060405180910390fd5b811561499557604e820287019660208201905b8881101561499257815181526020918201910161497a565b50505b60005b83811015614a5c57600e546065870196803560001a916001820135916021810135916041820135916061013560e01c908110614a055760405162461bcd60e51b815260040180806020018281038252602a815260200180615aab602a913960400191505060405180910390fd5b6001600160a01b0360ff861615614a2557614a2283858789615046565b90505b60601b8d5260148d0191909152600060348d0181905260e09190911b60448d015260488c01525050604e9098019750600101614998565b50614a7087604e8585610100030302614a8d565b50505050505050565b602002600490810135602481019291013590565b808201915b828110156136a55760008152602001614a92565b6001600160a01b038316614ba45760408051600080825260208201909252339083906040518082805190602001908083835b60208310614af75780518252601f199092019160209182019101614ad8565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614b59576040519150601f19603f3d011682016040523d82523d6000602084013e614b5e565b606091505b5050905080614b9e5760405162461bcd60e51b815260040180806020018281038252602a815260200180615bcf602a913960400191505060405180910390fd5b506136a5565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b60208310614c215780518252601f199092019160209182019101614c02565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614c83576040519150601f19603f3d011682016040523d82523d6000602084013e614c88565b606091505b5091509150818015614cb6575080511580614cb65750808060200190516020811015614cb357600080fd5b50515b614cf15760405162461bcd60e51b815260040180806020018281038252602c8152602001806156d5602c913960400191505060405180910390fd5b5050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663095ea7b360e01b178152925182516000946060949389169392918291908083835b60208310614d755780518252601f199092019160209182019101614d56565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114614dd7576040519150601f19603f3d011682016040523d82523d6000602084013e614ddc565b606091505b5091509150818015614e0a575080511580614e0a5750808060200190516020811015614e0757600080fd5b50515b614cf15760405162461bcd60e51b815260040180806020018281038252602a815260200180615de5602a913960400191505060405180910390fd5b604080516bffffffffffffffffffffffff1960608a901b16602080830191909152603482018990526001600160d01b031960d089811b821660548501526001600160d81b031960d88a811b8216605a87015289901b16605f8501526001600160e01b031960e088901b16606485015285901b1660688301528251604e81840381018252606e9093018452601354600160601b900463ffffffff16600090815260129092529290208054600260001960018316156101000201909116049190910490614f10908361523f565b601354604080516020808252855181830152855160ff861694600160601b900463ffffffff16937fdd5c7c5ea02d3c5d1621513faa6de53d474ee6f111eda6352a63e3dfe8c401199388939092839283019185019080838360005b83811015614f83578181015183820152602001614f6b565b50505050905090810190601f168015614fb05780820380516001836020036101000a031916815260200191505b509250505060405180910390a360808160010110612d635760138054600163ffffffff600160601b808404821692909201160263ffffffff60601b19909116179055505050505050505050565b6000615007615472565b838152602081018390526001604082015261502181615389565b949350505050565b6000615033615490565b83815260208101839052615021816153c6565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156150a75760405162461bcd60e51b8152600401808060200182810382526029815260200180615eb16029913960400191505060405180910390fd5b604080517fafd642c6a37a2e6887dc4ad5142f84197828a904e53d3204ecb1100329231eaa6020808301919091527fbe287413178bfeddef8d9753ad4be825ae998706a6dabff23978b59dccaea0ad828401527fff946cf82975b1a2b6e6d28c9a76a4b8d7a1fd0592b785cb92771933310f9ee7606083015260808083018990528351808403909101815260a09092019092528051910120600061514961140d565b82604051602001808061190160f01b81525060020183815260200182815260200192505050604051602081830303815290604052805190602001209050600060018286898960405160008152602001604052604051808581526020018460ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156151e2573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166152345760405162461bcd60e51b815260040180806020018281038252602b8152602001806159da602b913960400191505060405180910390fd5b979650505050505050565b8154600260018083161561010002038216048251808201602081106020841001600281146152e9576001811461530e578660005260208404602060002001600160028402018855602085068060200390508088018589016001836101000a0392508282511684540184556001840193506020820191505b808210156152d357815184556001840193506020820191506152b6565b815191036101000a908190040290915550614a70565b60028302826020036101000a846020036101000a602089015104020185018755614a70565b8660005260208404602060002001600160028402018855846020038088018589016001836101000a0392508282511660ff198a160184556020820191506001840193505b8082101561536f5781518455600184019350602082019150615352565b815191036101000a90819004029091555050505050505050565b6001546040516304b98e1d60e31b8152825160049091019081526000916001600160a01b0316906325cc70e890849080826060808383602061465d565b60008054604080516314d2f97b60e11b8152620100009092046001600160a01b0316916329a5f2f691859160040190819083908083838a818101518382015260200161465d565b60405180608001604052806004906020820280368337509192915050565b50805460018160011615610100020316600290046000825580601f10615451575061546f565b601f01602090049060005260206000209081019061546f91906154ae565b50565b60405180606001604052806003906020820280368337509192915050565b60405180604001604052806002906020820280368337509192915050565b5b808211156154c357600081556001016154af565b5090565b600080858511156154d6578182fd5b838611156154e2578182fd5b505082019391909203915056fe496e7374616e7457697468647261774d616e616765723a3a5f746f6b656e325553443a20544f4b454e5f444543494d414c535f4f564552464c4f574865726d657a3a3a5f636f6e73747275637443697263756974496e7075743a20494e56414c49445f464545494458434f4f5244494e41544f525f4c454e475448496e7374616e7457697468647261774d616e616765723a3a757064617465546f6b656e45786368616e67653a20494e56414c49445f41525241595f4c454e4754484865726d657a3a3a757064617465466f7267654c314c32426174636854696d656f75743a204d41585f464f52474554494d454f55545f4558434545444865726d657a3a3a666f72676542617463683a20494e56414c49445f50524f4f464865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4558434545445f4c494d49544865726d657a3a3a5f736166655472616e7366657246726f6d3a2045524332305f5452414e5346455246524f4d5f4641494c45444865726d657a3a3a5f7065726d69743a205045524d49545f4f574e45525f4d5553545f42455f5448455f53454e4445524865726d657a3a3a5f6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4d5553545f42455f305f49465f455849544865726d657a3a3a5f736166655472616e736665723a2045524332305f5452414e534645525f4641494c4544496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a204d41585f4e554d5f4255434b4554534865726d657a3a3a666f72676542617463683a2041554354494f4e5f44454e494544496e7374616e7457697468647261774d616e616765723a3a7570646174655769746864726177616c44656c61793a204558434545445f4d41585f5749544844524157414c5f44454c41594865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f4352454154455f4143434f554e545f574954485f4e4f5f424142594a55424865726d657a3a3a616464546f6b656e3a20414444524553535f305f494e56414c49444865726d657a3a3a757064617465566572696669657273205645524946494552535f414c52454144595f555044415445444865726d657a3a3a666f72676542617463683a20494e54454e414c5f54585f4e4f545f414c4c4f5745444865726d657a3a3a616464546f6b656e3a20544f4b454e5f4c4953545f46554c4c4865726d657a3a3a696e697469616c697a654865726d657a20414444524553535f305f4e4f545f56414c49444865726d657a3a3a5f6164644c315472616e73616374696f6e3a20414d4f554e545f4558434545445f4c494d49544865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f46524f4d4944584865726d657a3a3a5f7065726d69743a205350454e4445525f4d5553545f42455f544849534865726d657a3a3a6164644c315472616e73616374696f6e3a204d53475f56414c55455f4e4f545f455155414c5f304865726d657a3a3a77697468647261774d65726b6c6550726f6f663a20494e5354414e545f57495448445241575f5741535445445f464f525f544849535f5553445f52414e4745496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65644865726d657a48656c706572733a3a5f636865636b5369673a20494e56414c49445f5349474e41545552454865726d657a3a3a757064617465566572696669657273204f4e4c595f4445504c4f5945524865726d657a3a3a77697468647261774d65726b6c6550726f6f663a2057495448445241575f414c52454144595f444f4e45536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774865726d657a3a3a7769746864726177436972637569743a2057495448445241575f414c52454144595f444f4e454865726d657a3a3a5f6275696c644c31446174613a20544f4b454e5f4e4f545f524547495354455245444865726d657a3a3a7769746864726177436972637569743a20494e5354414e545f57495448445241575f5741535445445f464f525f544849535f5553445f52414e47454865726d657a3a3a5f6164644c315472616e73616374696f6e3a20424142594a55425f4d5553545f42455f305f49465f4e4f545f4352454154455f4143434f554e544865726d657a3a3a5f6275696c644c31446174613a204c315f54585f4f564552464c4f574865726d657a3a3a5f6164644c315472616e73616374696f6e3a20494e56414c49445f544f4944584865726d657a3a3a7769746864726177436972637569743a20494e56414c49445f5a4b5f50524f4f464865726d657a3a3a5f736166655472616e736665723a204554485f5452414e534645525f4641494c45444865726d657a3a3a5f7065726d69743a205045524d49545f414d4f554e545f444f45535f4e4f545f4d415443484865726d657a3a3a666f72676542617463683a204c314c3242415443485f52455155495245444865726d657a3a3a6164644c315472616e73616374696f6e3a20544f4b454e5f4e4f545f524547495354455245444865726d657a3a3a77697468647261774d65726b6c6550726f6f663a20534d545f50524f4f465f494e56414c4944496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a20524154455f424c4f434b535f4d5553545f42455f4d4f52455f5448414e5f304865726d657a3a3a616464546f6b656e3a20544f54414c5f535550504c595f5a45524f4865726d657a3a3a5f636f6e73747275637443697263756974496e7075743a204c325f54585f4f564552464c4f57496e7374616e7457697468647261774d616e616765723a3a6f6e6c79476f7665726e616e63653a204f4e4c595f474f5645524e414e43455f41444452455353496e7374616e7457697468647261774d616e616765723a3a7570646174654275636b657473506172616d65746572733a205749544844524157414c535f4d5553545f42455f4c4553535f5448414e5f4d41585749544844524157414c534865726d657a3a3a5f73616665417070726f76653a2045524332305f415050524f56455f4641494c45444865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f45524332305f444f45535f4e4f545f4d415443484865726d657a3a3a5f6164644c315472616e73616374696f6e3a20414d4f554e545f4d5553545f42455f305f49465f4e4f545f5452414e534645524865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204e4f545f56414c49445f43414c4c4865726d657a48656c706572733a3a5f636865636b5369673a20494e56414c49445f535f56414c55454865726d657a3a3a6164644c315472616e73616374696f6e3a204c4f4144414d4f554e545f4554485f444f45535f4e4f545f4d41544348a2646970667358221220e5fc23964ebee4391cb37d0cad23ee3495099d877a43d55d3932956e0ec65a9c64736f6c634300060c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/eth/contracts/abi/HermezAuctionProtocol.json b/eth/contracts/abi/HermezAuctionProtocol.json new file mode 100644 index 000000000..40a1f95f9 --- /dev/null +++ b/eth/contracts/abi/HermezAuctionProtocol.json @@ -0,0 +1,988 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "HermezAuctionProtocol", + "sourceName": "contracts/auction/HermezAuctionProtocol.sol", + "abi": [ + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + } + ], + "name": "HEZClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "donationAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "bootCoordinatorAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "bootCoordinatorURL", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "outbidding", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "slotDeadline", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "closedAuctionSlots", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "openAuctionSlots", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16[3]", + "name": "allocationRatio", + "type": "uint16[3]" + } + ], + "name": "InitializeHermezAuctionProtocolEvent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16[3]", + "name": "newAllocationRatio", + "type": "uint16[3]" + } + ], + "name": "NewAllocationRatio", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint128", + "name": "slot", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "bidAmount", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "address", + "name": "bidder", + "type": "address" + } + ], + "name": "NewBid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newBootCoordinator", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "newBootCoordinatorURL", + "type": "string" + } + ], + "name": "NewBootCoordinator", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "newClosedAuctionSlots", + "type": "uint16" + } + ], + "name": "NewClosedAuctionSlots", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "slotSet", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "newInitialMinBid", + "type": "uint128" + } + ], + "name": "NewDefaultSlotSetBid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newDonationAddress", + "type": "address" + } + ], + "name": "NewDonationAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "slotToForge", + "type": "uint128" + } + ], + "name": "NewForge", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bidder", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "slotToForge", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "burnAmount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "donationAmount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "governanceAmount", + "type": "uint128" + } + ], + "name": "NewForgeAllocated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "newOpenAuctionSlots", + "type": "uint16" + } + ], + "name": "NewOpenAuctionSlots", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "newOutbidding", + "type": "uint16" + } + ], + "name": "NewOutbidding", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "newSlotDeadline", + "type": "uint8" + } + ], + "name": "NewSlotDeadline", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "bidder", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "coordinatorURL", + "type": "string" + } + ], + "name": "SetCoordinator", + "type": "event" + }, + { + "inputs": [], + "name": "BLOCKS_PER_SLOT", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INITIAL_MINIMAL_BIDDING", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bootCoordinatorURL", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "internalType": "uint256", + "name": "blockNumber", + "type": "uint256" + } + ], + "name": "canForge", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "slotSet", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "newInitialMinBid", + "type": "uint128" + } + ], + "name": "changeDefaultSlotSetBid", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimHEZ", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "slot", + "type": "uint128" + } + ], + "name": "claimPendingHEZ", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "coordinators", + "outputs": [ + { + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "internalType": "string", + "name": "coordinatorURL", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forger", + "type": "address" + } + ], + "name": "forge", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "genesisBlock", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAllocationRatio", + "outputs": [ + { + "internalType": "uint16[3]", + "name": "", + "type": "uint16[3]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getBootCoordinator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "bidder", + "type": "address" + } + ], + "name": "getClaimableHEZ", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getClosedAuctionSlots", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCurrentSlotNumber", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "slotSet", + "type": "uint8" + } + ], + "name": "getDefaultSlotSetBid", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDonationAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "slot", + "type": "uint128" + } + ], + "name": "getMinBidBySlot", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOpenAuctionSlots", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOutbidding", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSlotDeadline", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "blockNumber", + "type": "uint128" + } + ], + "name": "getSlotNumber", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "slot", + "type": "uint128" + } + ], + "name": "getSlotSet", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "governanceAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "internalType": "uint128", + "name": "genesis", + "type": "uint128" + }, + { + "internalType": "address", + "name": "hermezRollupAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_governanceAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "donationAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "bootCoordinatorAddress", + "type": "address" + }, + { + "internalType": "string", + "name": "_bootCoordinatorURL", + "type": "string" + } + ], + "name": "hermezAuctionProtocolInitializer", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "hermezRollup", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "pendingBalances", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "slot", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bidAmount", + "type": "uint128" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "processBid", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "startingSlot", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "endingSlot", + "type": "uint128" + }, + { + "internalType": "bool[6]", + "name": "slotSets", + "type": "bool[6]" + }, + { + "internalType": "uint128", + "name": "maxBid", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "minBid", + "type": "uint128" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "processMultiBid", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16[3]", + "name": "newAllocationRatio", + "type": "uint16[3]" + } + ], + "name": "setAllocationRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newBootCoordinator", + "type": "address" + }, + { + "internalType": "string", + "name": "newBootCoordinatorURL", + "type": "string" + } + ], + "name": "setBootCoordinator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "newClosedAuctionSlots", + "type": "uint16" + } + ], + "name": "setClosedAuctionSlots", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "forger", + "type": "address" + }, + { + "internalType": "string", + "name": "coordinatorURL", + "type": "string" + } + ], + "name": "setCoordinator", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newDonationAddress", + "type": "address" + } + ], + "name": "setDonationAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "newOpenAuctionSlots", + "type": "uint16" + } + ], + "name": "setOpenAuctionSlots", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "newOutbidding", + "type": "uint16" + } + ], + "name": "setOutbidding", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "newDeadline", + "type": "uint8" + } + ], + "name": "setSlotDeadline", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "name": "slots", + "outputs": [ + { + "internalType": "address", + "name": "bidder", + "type": "address" + }, + { + "internalType": "bool", + "name": "fulfilled", + "type": "bool" + }, + { + "internalType": "bool", + "name": "forgerCommitment", + "type": "bool" + }, + { + "internalType": "uint128", + "name": "bidAmount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "closedMinBid", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tokenHEZ", + "outputs": [ + { + "internalType": "contract IHEZToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b506145a4806100206000396000f3fe608060405234801561001057600080fd5b506004361061023d5760003560e01c806372ca58a31161013b578063aebd6d98116100b8578063d92bdda31161007c578063d92bdda314610a82578063dfd5281b14610aa3578063e606591414610ac4578063ec29159b14610acc578063ecdae41b14610b0c5761023d565b8063aebd6d98146109c4578063b3dc7bb1146109cc578063b5f7f2f0146109f2578063bc415567146109fa578063c63de51514610a615761023d565b806383b1f6a0116100ff57806383b1f6a01461088857806387e6b6bb146108c8578063a48af096146108e8578063ac4b901214610996578063ac5f658b1461099e5761023d565b806372ca58a31461077b578063795053d3146107f857806379a135e3146108005780637c643b701461080857806382787405146108365761023d565b80634e5a5178116101c95780635cca49031161018d5780635cca49031461058f5780635e73a67f146105b55780636cbdc3df146106995780636dfe47c91461074d5780636f48e79b146107555761023d565b80634e5a51781461044457806354c03ab71461046a57806355b442e61461048e578063564e6a7114610496578063583ad0dd146104b65761023d565b806337d1bd0b1161021057806337d1bd0b1461034257806341d42c23146103685780634b93b7fa1461038e5780634cdc9c631461041d5780634da9639d146104255761023d565b80630c4da4f6146102425780630eeaf0801461026657806313de9af21461031c5780632243de471461033a575b600080fd5b61024a610b32565b604080516001600160801b039092168252519081900360200190f35b61031a6004803603604081101561027c57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156102a657600080fd5b8201836020820111156102b857600080fd5b803590602001918460018302840111600160201b831117156102d957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610b42945050505050565b005b610324610cf0565b6040805160ff9092168252519081900360200190f35b610324610cff565b61024a6004803603602081101561035857600080fd5b50356001600160801b0316610d04565b61031a6004803603602081101561037e57600080fd5b50356001600160801b0316610ea8565b61031a600480360360808110156103a457600080fd5b6001600160801b0382358116926020810135821692604082013590921691810190608081016060820135600160201b8111156103df57600080fd5b8201836020820111156103f157600080fd5b803590602001918460018302840111600160201b8311171561041257600080fd5b509092509050611102565b61024a61140c565b61042d61141b565b6040805161ffff9092168252519081900360200190f35b61031a6004803603602081101561045a57600080fd5b50356001600160a01b031661142c565b6104726119d7565b604080516001600160a01b039092168252519081900360200190f35b61042d6119e6565b61024a600480360360208110156104ac57600080fd5b503560ff166119f0565b61031a60048036036101808110156104cd57600080fd5b6040805160c081810183526001600160801b038535811695602081013582169594810135909116938101929091610120830191906060840190600690839083908082843760009201919091525091946001600160801b0384358116956020860135909116949193509150606081019060400135600160201b81111561055157600080fd5b82018360208201111561056357600080fd5b803590602001918460018302840111600160201b8311171561058457600080fd5b509092509050611a28565b61024a600480360360208110156105a557600080fd5b50356001600160a01b0316611e0a565b61031a600480360360e08110156105cb57600080fd5b6001600160a01b0382358116926001600160801b036020820135169260408201358316926060830135811692608081013582169260a08201359092169181019060e0810160c0820135600160201b81111561062557600080fd5b82018360208201111561063757600080fd5b803590602001918460018302840111600160201b8311171561065857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611e2e945050505050565b61031a600480360360408110156106af57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156106d957600080fd5b8201836020820111156106eb57600080fd5b803590602001918460018302840111600160201b8311171561070c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506121f0945050505050565b61031a612313565b61031a6004803603602081101561076b57600080fd5b50356001600160a01b03166124e7565b6107836125c5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156107bd5781810151838201526020016107a5565b50505050905090810190601f1680156107ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610472612653565b610472612662565b61031a6004803603604081101561081e57600080fd5b506001600160801b0381358116916020013516612671565b61031a6004803603606081101561084c57600080fd5b81019080806060019060038060200260405190810160405280929190826003602002808284376000920191909152509194506128d49350505050565b6108b46004803603604081101561089e57600080fd5b506001600160a01b038135169060200135612a48565b604080519115158252519081900360200190f35b61031a600480360360208110156108de57600080fd5b503560ff16612a5d565b61090e600480360360208110156108fe57600080fd5b50356001600160a01b0316612b43565b60405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561095a578181015183820152602001610942565b50505050905090810190601f1680156109875780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61042d612bf7565b61024a600480360360208110156109b457600080fd5b50356001600160801b0316612c08565b610472612c1e565b61024a600480360360208110156109e257600080fd5b50356001600160801b0316612c2d565b610472612c67565b610a2060048036036020811015610a1057600080fd5b50356001600160801b0316612c76565b604080516001600160a01b0390961686529315156020860152911515848401526001600160801b039081166060850152166080830152519081900360a00190f35b61031a60048036036020811015610a7757600080fd5b503561ffff16612cc4565b61031a60048036036020811015610a9857600080fd5b503561ffff16612d6b565b61031a60048036036020811015610ab957600080fd5b503561ffff16612e12565b61024a612eff565b610ad4612f0d565b6040518082606080838360005b83811015610af9578181015183820152602001610ae1565b5050505090500191505060405180910390f35b61024a60048036036020811015610b2257600080fd5b50356001600160a01b0316612f6f565b6000610b3d43612c2d565b905090565b604080516000815260208082018084528251902084519093859301918291908401908083835b60208310610b875780518252601f199092019160209182019101610b68565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001201415610bff5760405162461bcd60e51b81526004018080602001828103825260348152602001806140af6034913960400191505060405180910390fd5b33600090815260416020908152604090912080546001600160a01b0319166001600160a01b0385161781558251610c3e92600190920191840190613ab6565b50816001600160a01b0316336001600160a01b03167f5246b2ac9ee77efe2e64af6df00055d97e2d6e1b277f5a8d17ba5bca1a573da0836040518080602001828103825283818151815260200191508051906020019080838360005b83811015610cb2578181015183820152602001610c9a565b50505050905090810190601f168015610cdf5780820380516001836020036101000a031916815260200191505b509250505060405180910390a35050565b603e5462010000900460ff1690565b602881565b603c54600090600160801b900461ffff16610d1d610b32565b016001600160801b0316826001600160801b031611610d6d5760405162461bcd60e51b8152600401808060200182810382526036815260200180613f356036913960400191505060405180910390fd5b6000610d7883612c08565b6001600160801b038085166000908152603f60205260409020600101549192501615610e1257603e546001600160801b038085166000908152603f6020526040902060010154610e0d92610de99261271092610dda9291169061ffff16612f8a565b6001600160801b031690613004565b6001600160801b038086166000908152603f60205260409020600101541690613046565b610ea1565b603e54610ea190610e659061271090610dda9061ffff1660396001600160801b03871660068110610e3f57fe5b60028104919091015460019091166010026101000a90046001600160801b031690612f8a565b6039836001600160801b031660068110610e7b57fe5b60028104919091015460019091166010026101000a90046001600160801b031690613046565b9392505050565b610eb0610b32565b6001600160801b0316816001600160801b031610610eff5760405162461bcd60e51b815260040180806020018281038252603d815260200180613d39603d913960400191505060405180910390fd5b6001600160801b0381166000908152603f6020526040902054600160a01b900460ff1615610f5e5760405162461bcd60e51b815260040180806020018281038252603d815260200180613cfc603d913960400191505060405180910390fd5b6001600160801b038082166000908152603f60205260408120600101549091600160801b9091041615610fb5576001600160801b038083166000908152603f6020526040902060010154600160801b900416610ff3565b6039610fc083612c08565b6001600160801b031660068110610fd357fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b038381166000908152603f60205260409020600101549192508083169116106110545760405162461bcd60e51b815260040180806020018281038252603d815260200180613cfc603d913960400191505060405180910390fd5b6001600160801b038083166000908152603f60209081526040808320600181018054868816600160801b029087161790819055815460ff60a01b1916600160a01b17918290556001600160a01b03909116845291819052909120546110bd929081169116613046565b6001600160801b039283166000908152603f60209081526040808320546001600160a01b0316835290819052902080546001600160801b031916919093161790915550565b336000908152604160205260409020546001600160a01b03166111565760405162461bcd60e51b815260040180806020018281038252603d815260200180613d76603d913960400191505060405180910390fd5b603c54600160801b900461ffff1661116c610b32565b016001600160801b0316846001600160801b0316116111bc5760405162461bcd60e51b81526004018080602001828103825260318152602001806144686031913960400191505060405180910390fd5b6111c584610d04565b6001600160801b0316836001600160801b031610156112155760405162461bcd60e51b8152600401808060200182810382526030815260200180613e5e6030913960400191505060405180910390fd5b603c5461ffff600160901b8204811691600160801b900416611235610b32565b01016001600160801b0316846001600160801b031611156112875760405162461bcd60e51b81526004018080602001828103825260338152602001806141bd6033913960400191505060405180910390fd5b80156112a1576112a1856001600160801b031683836130ac565b603354604080516323b872dd60e01b81523360048201523060248201526001600160801b038816604482015290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561130357600080fd5b505af1158015611317573d6000803e3d6000fd5b505050506040513d602081101561132d57600080fd5b505161136a5760405162461bcd60e51b8152600401808060200182810382526038815260200180613e8e6038913960400191505060405180910390fd5b3360009081526040602081905290205461138d906001600160801b031686613046565b33600090815260406020819052902080546001600160801b0319166001600160801b039283161790819055848216911610156113fa5760405162461bcd60e51b81526004018080602001828103825260358152602001806141886035913960400191505060405180910390fd5b61140584843361334b565b5050505050565b603c546001600160801b031681565b603c54600160801b900461ffff1690565b6034546001600160a01b031633146114755760405162461bcd60e51b815260040180806020018281038252603081526020018061428f6030913960400191505060405180910390fd5b61147f814361352b565b6114ba5760405162461bcd60e51b815260040180806020018281038252602a815260200180614326602a913960400191505060405180910390fd5b60006114c4610b32565b6001600160801b0381166000908152603f6020526040902054909150600160a81b900460ff1661157f57603c5460009061153490611524906001600160801b03908116906115159086166028612f8a565b6001600160801b031690613046565b6001600160801b034316906137df565b603e5490915062010000900460ff166001600160801b038216101561157d576001600160801b0382166000908152603f60205260409020805460ff60a81b1916600160a81b1790555b505b6001600160801b0381166000908152603f6020526040902054600160a01b900460ff16611994576001600160801b038082166000908152603f60205260409020805460ff60a01b1916600160a01b178155600101541615611994576001600160801b038082166000908152603f60205260408120600101549091600160801b9091041615611631576001600160801b038083166000908152603f6020526040902060010154600160801b90041661166f565b603961163c83612c08565b6001600160801b03166006811061164f57fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b038381166000908152603f602052604090206001015491925080831691161015611727576001600160801b038083166000908152603f60209081526040808320600181015490546001600160a01b0316845291819052909120546116de929081169116613046565b6001600160801b038381166000908152603f60209081526040808320546001600160a01b0316835290819052902080546001600160801b03191692909116919091179055611992565b6001600160801b038281166000908152603f6020526040812060010154603d549216916117619061271090610dda90859061ffff16612f8a565b603d549091506000906117909061271090610dda906001600160801b0387169062010000900461ffff16612f8a565b603d549091506000906117c09061271090610dda906001600160801b03881690600160201b900461ffff16612f8a565b60335460408051630852cd8d60e31b81526001600160801b038716600482015290519293506001600160a01b03909116916342966c68916024808201926020929091908290030181600087803b15801561181957600080fd5b505af115801561182d573d6000803e3d6000fd5b505050506040513d602081101561184357600080fd5b50516118805760405162461bcd60e51b815260040180806020018281038252602f815260200180613f6b602f913960400191505060405180910390fd5b6036546001600160a01b03166000908152604060208190529020546118ae906001600160801b031683613046565b6036546001600160a01b0390811660009081526040602081905280822080546001600160801b0319166001600160801b03958616179055603554909216815220546118fa911682613046565b6035546001600160a01b0390811660009081526040602081815281832080546001600160801b0319166001600160801b039687161790558a8516808452603f82529282902054825189871681528887169281019290925294861681830152905191938b84169316917fd64ebb43f4c2b91022b97389834432f1027ef55586129ba05a3a3065b2304f05916060908290030190a4505050505b505b6040516001600160801b038216906001600160a01b038416907f7cae662d4cfa9d9c5575c65f0cc41a858c51ca14ebcbd02a802a62376c3ad23890600090a35050565b6036546001600160a01b031690565b603e5461ffff1690565b600060398260ff1660068110611a0257fe5b600291828204019190066010029054906101000a90046001600160801b03169050919050565b603c54600160801b900461ffff16611a3e610b32565b016001600160801b0316876001600160801b031611611a8e5760405162461bcd60e51b8152600401808060200182810382526035815260200180613f006035913960400191505060405180910390fd5b603c5461ffff600160901b8204811691600160801b900416611aae610b32565b01016001600160801b0316866001600160801b03161115611b005760405162461bcd60e51b81526004018080602001828103825260378152602001806143fb6037913960400191505060405180910390fd5b826001600160801b0316846001600160801b03161015611b515760405162461bcd60e51b8152600401808060200182810382526041815260200180613f9a6041913960600191505060405180910390fd5b336000908152604160205260409020546001600160a01b0316611ba55760405162461bcd60e51b81526004018080602001828103825260418152602001806144996041913960600191505060405180910390fd5b8015611bbf57611bbf886001600160801b031683836130ac565b603354604080516323b872dd60e01b81523360048201523060248201526001600160801b038b16604482015290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015611c2157600080fd5b505af1158015611c35573d6000803e3d6000fd5b505050506040513d6020811015611c4b57600080fd5b5051611c885760405162461bcd60e51b815260040180806020018281038252603d815260200180613db3603d913960400191505060405180910390fd5b33600090815260406020819052902054611cab906001600160801b031689613046565b33600090815260406020819052812080546001600160801b0319166001600160801b039390931692909217909155875b876001600160801b0316816001600160801b031611611dfe576000611cff82610d04565b9050856001600160801b0316816001600160801b031611611d2257859250611d68565b856001600160801b0316816001600160801b0316118015611d555750866001600160801b0316816001600160801b031611155b15611d6257809250611d68565b50611df6565b87611d7283612c08565b6001600160801b031660068110611d8557fe5b602002015115611df457336000908152604060208190529020546001600160801b0380851691161015611de95760405162461bcd60e51b81526004018080602001828103825260398152602001806143866039913960400191505060405180910390fd5b611df482843361334b565b505b600101611cdb565b50505050505050505050565b6001600160a01b03166000908152604060208190529020546001600160801b031690565b600054610100900460ff1680611e475750611e47613821565b80611e55575060005460ff16155b611e905760405162461bcd60e51b815260040180806020018281038252602e815260200180614127602e913960400191505060405180910390fd5b600054610100900460ff16158015611ebb576000805460ff1961ff0019909116610100171660011790555b611ec3613827565b6001600160a01b038616611f085760405162461bcd60e51b815260040180806020018281038252604b8152602001806141f0604b913960600191505060405180910390fd5b603e80546103e861ffff199091161762ff0000191662140000179055603c805461ffff60801b1916600160811b1761ffff60901b1916608760951b17905560408051606081018252610fa080825260208201526107d091810191909152611f7390603d906003613b34565b506040805160c08101825269d3c21bcecceda100000080825260208201819052918101829052606081018290526080810182905260a0810191909152611fbd906039906006613bc6565b5043876001600160801b031610156120065760405162461bcd60e51b815260040180806020018281038252604d815260200180614062604d913960600191505060405180910390fd5b603380546001600160a01b03199081166001600160a01b038b811691909117909255603c80546001600160801b0319166001600160801b038b1617905560348054821689841617905560358054821688841617905560368054821687841617905560378054909116918516919091179055815161208a906038906020850190613ab6565b50603e54603c54604080516001600160a01b0388811682528716602082015261ffff808516606083018190526201000090950460ff1660808301819052600160801b8504821660a08401819052600160901b90950490911660c083018190527f9717e4e04c13817c600463a7a450110c754fd78758cdd538603f30528a24ce4b958a958a958a959294939192603d918101610140820183600060e085015b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116121285750505082810382528851815288516020918201918a019080838360005b8381101561219357818101518382015260200161217b565b50505050905090810190601f1680156121c05780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390a180156121e6576000805461ff00191690555b5050505050505050565b6035546001600160a01b031633146122395760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603780546001600160a01b0319166001600160a01b0384161790558051612267906038906020840190613ab6565b5060375460408051602080825284518183015284516001600160a01b03909416937f0487eab4c1da34bf653268e33bee8bfec7dacfd6f3226047197ebf872293cfd6938693928392918301919085019080838360005b838110156122d55781810151838201526020016122bd565b50505050905090810190601f1680156123025780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b6002600154141561236b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155600061237b33611e0a565b90506000816001600160801b0316116123c55760405162461bcd60e51b815260040180806020018281038252603381526020018061423b6033913960400191505060405180910390fd5b3360008181526040602081815281832080546001600160801b0319169055603354825163a9059cbb60e01b815260048101959095526001600160801b038616602486015291516001600160a01b039092169363a9059cbb93604480830194928390030190829087803b15801561243a57600080fd5b505af115801561244e573d6000803e3d6000fd5b505050506040513d602081101561246457600080fd5b50516124a15760405162461bcd60e51b81526004018080602001828103825260368152602001806143506036913960400191505060405180910390fd5b604080516001600160801b0383168152905133917f199ef0cb54d2b296ff6eaec2721bacf0ca3fd8344a43f5bdf4548b34dfa2594f919081900360200190a25060018055565b6035546001600160a01b031633146125305760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b6001600160a01b0381166125755760405162461bcd60e51b815260040180806020018281038252603c8152602001806143bf603c913960400191505060405180910390fd5b603680546001600160a01b0319166001600160a01b0383811691909117918290556040519116907fa62863cbad1647a2855e9cd39d04fa6dfd32e1b9cfaff1aaf6523f4aaafeccd790600090a250565b6038805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561264b5780601f106126205761010080835404028352916020019161264b565b820191906000526020600020905b81548152906001019060200180831161262e57829003601f168201915b505050505081565b6035546001600160a01b031681565b6033546001600160a01b031681565b6035546001600160a01b031633146126ba5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b6006826001600160801b0316106127025760405162461bcd60e51b8152600401808060200182810382526042815260200180613e1c6042913960600191505060405180910390fd5b6039826001600160801b03166006811061271857fe5b60028104919091015460019091166010026101000a90046001600160801b03166127735760405162461bcd60e51b8152600401808060200182810382526042815260200180613fdb6042913960600191505060405180910390fd5b600061277d610b32565b9050805b603c54600160801b900461ffff1682016001600160801b0390811690821611612837576001600160801b038082166000908152603f6020526040902060010154600160801b90041661282f5760396127d882612c08565b6001600160801b0316600681106127eb57fe5b6002810491909101546001600160801b038381166000908152603f60205260409020600190810180548316919094166010026101000a90920416600160801b021790555b600101612781565b50816039846001600160801b03166006811061284f57fe5b600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055507fa922aa010d1ff8e70b2aa9247d891836795c3d3ba2a543c37c91a44dc4a50172838360405180836001600160801b03168152602001826001600160801b031681526020019250505060405180910390a1505050565b6035546001600160a01b0316331461291d5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b805161271061ffff909116118015906129435750612710816001602002015161ffff1611155b801561295c5750612710816002602002015161ffff1611155b80156129865750806002602002015181600160200201518260006020020151010161ffff16612710145b6129c15760405162461bcd60e51b815260040180806020018281038252604581526020018061401d6045913960600191505060405180910390fd5b6129ce603d826003613b34565b506040517f0bb59eceb12f1bdb63e4a7d57c70d6473fefd7c3f51af5a3604f7e97197073e490603d9060608101826000835b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411612a00579050505091505060405180910390a150565b6000612a54838361352b565b90505b92915050565b6035546001600160a01b03163314612aa65760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b602860ff82161115612ae95760405162461bcd60e51b81526004018080602001828103825260448152602001806140e36044913960600191505060405180910390fd5b603e805460ff8084166201000090810262ff0000199093169290921792839055604080519290930416815290517f4a0d90b611c15e02dbf23b10f35b936cf2c77665f8c77822d3eca131f9d986d39181900360200190a150565b6041602090815260009182526040918290208054600180830180548651600261010094831615949094026000190190911692909204601f81018690048602830186019096528582526001600160a01b03909216949293909290830182828015612bed5780601f10612bc257610100808354040283529160200191612bed565b820191906000526020600020905b815481529060010190602001808311612bd057829003601f168201915b5050505050905082565b603c54600160901b900461ffff1690565b6000612a576001600160801b03831660066138cd565b6034546001600160a01b031681565b603c546000906001600160801b039081169083161015612c4e576000612a57565b50603c5460286001600160801b03918216909203160490565b6037546001600160a01b031690565b603f60205260009081526040902080546001909101546001600160a01b0382169160ff600160a01b8204811692600160a81b90920416906001600160801b0380821691600160801b90041685565b6035546001600160a01b03163314612d0d5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603c805461ffff808416600160901b90810261ffff60901b199093169290921792839055604080519290930416815290517f3da0492dea7298351bc14d1c0699905fd0657c33487449751af50fc0c8b593f19181900360200190a150565b6035546001600160a01b03163314612db45760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603c805461ffff808416600160801b90810261ffff60801b199093169290921792839055604080519290930416815290517fc78051d3757db196b1e445f3a9a1380944518c69b5d7922ec747c54f0340a4ea9181900360200190a150565b6035546001600160a01b03163314612e5b5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b60018161ffff16118015612e7457506127108161ffff16105b612eaf5760405162461bcd60e51b815260040180806020018281038252603a815260200180613ec6603a913960400191505060405180910390fd5b603e805461ffff191661ffff838116919091179182905560408051929091168252517fd3748b8c326e93d12af934fbf87471e315a89bc3f7b8222343acf0210edf248e916020908290030190a150565b69d3c21bcecceda100000081565b612f15613c67565b60408051606081019182905290603d90600390826000855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411612f2d5790505050505050905090565b6040602081905260009182529020546001600160801b031681565b60006001600160801b038316612fa257506000612a57565b8282026001600160801b038084169080861690831681612fbe57fe5b046001600160801b031614612a545760405162461bcd60e51b815260040180806020018281038252602181526020018061426e6021913960400191505060405180910390fd5b6000612a5483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061390f565b60008282016001600160801b038085169082161015612a54576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000828260208110156130be57600080fd5b50356001600160e01b031916905063d505accf60e01b81146131115760405162461bcd60e51b815260040180806020018281038252602e8152602001806144da602e913960400191505060405180910390fd5b6000808080808080613126896004818d613cd3565b60e081101561313457600080fd5b506001600160a01b038135811698506020820135169650604081013595506060810135945060ff608082013516935060a0810135925060c0013590503387146131ae5760405162461bcd60e51b81526004018080602001828103825260368152602001806145396036913960400191505060405180910390fd5b6001600160a01b03861630146131f55760405162461bcd60e51b81526004018080602001828103825260368152602001806144326036913960400191505060405180910390fd5b8a85146132335760405162461bcd60e51b815260040180806020018281038252602c815260200180613df0602c913960400191505060405180910390fd5b603354604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905260ff871660a483015260c4820186905260e48083018690528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b178152925182519190941693919282918083835b602083106132d45780518252601f1990920191602091820191016132b5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613336576040519150601f19603f3d011682016040523d82523d6000602084013e61333b565b606091505b5050505050505050505050505050565b6001600160801b038084166000908152603f6020526040902080546001909101546001600160a01b039091169190811690841681106133bb5760405162461bcd60e51b81526004018080602001828103825260318152602001806142f56031913960400191505060405180910390fd5b6001600160a01b0383166000908152604060208190529020546133e7906001600160801b0316856137df565b6001600160a01b0384811660008181526040602081815281832080546001600160801b03199081166001600160801b03988916179091558b87168452603f909152912080546001600160a01b031916909217825560019190910180549091169287169290921790915582161580159061346857506001600160801b03811615155b156134d0576001600160a01b038216600090815260406020819052902054613499906001600160801b031682613046565b6001600160a01b038316600090815260406020819052902080546001600160801b0319166001600160801b03929092169190911790555b826001600160a01b0316856001600160801b03167fd48e8329cdb2fb109b4fe445d7b681a74b256bff16e6f7f33b9d4fbe9038e4338660405180826001600160801b0316815260200191505060405180910390a35050505050565b6000600160801b821061356f5760405162461bcd60e51b81526004018080602001828103825260318152602001806145086031913960400191505060405180910390fd5b603c546001600160801b03168210156135b95760405162461bcd60e51b81526004018080602001828103825260338152602001806141556033913960400191505060405180910390fd5b60006135c483612c2d565b603c549091506000906135fe906135ee906001600160801b03908116906115159086166028612f8a565b6001600160801b038616906137df565b6001600160801b038084166000908152603f602052604081206001015492935091600160801b90041615613656576001600160801b038084166000908152603f6020526040902060010154600160801b900416613694565b603961366184612c08565b6001600160801b03166006811061367457fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b0384166000908152603f6020526040902054909150600160a81b900460ff161580156136db5750603e5462010000900460ff166001600160801b03831610155b156136ec5760019350505050612a57565b6001600160801b0383166000908152603f60209081526040808320546001600160a01b039081168452604190925290912054811690871614801561375057506001600160801b038381166000908152603f6020526040902060010154818316911610155b156137615760019350505050612a57565b6037546001600160a01b0387811691161480156137c257506001600160801b038381166000908152603f6020526040902060010154818316911610806137c257506001600160801b038084166000908152603f602052604090206001015416155b156137d35760019350505050612a57565b60009350505050612a57565b6000612a5483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506139cc565b303b1590565b600054610100900460ff16806138405750613840613821565b8061384e575060005460ff16155b6138895760405162461bcd60e51b815260040180806020018281038252602e815260200180614127602e913960400191505060405180910390fd5b600054610100900460ff161580156138b4576000805460ff1961ff0019909116610100171660011790555b6001805580156138ca576000805461ff00191690555b50565b6000612a5483836040518060400160405280601881526020017f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000815250613a39565b6000816001600160801b0384166139a45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613969578181015183820152602001613951565b50505050905090810190601f1680156139965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000836001600160801b0316856001600160801b0316816139c257fe5b0495945050505050565b6000836001600160801b0316836001600160801b031611158290613a315760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613969578181015183820152602001613951565b505050900390565b6000816001600160801b038416613a915760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613969578181015183820152602001613951565b50826001600160801b0316846001600160801b031681613aad57fe5b06949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10613af757805160ff1916838001178555613b24565b82800160010185558215613b24579182015b82811115613b24578251825591602001919060010190613b09565b50613b30929150613c85565b5090565b600183019183908215613bba5791602002820160005b83821115613b8a57835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302613b4a565b8015613bb85782816101000a81549061ffff0219169055600201602081600101049283019260010302613b8a565b505b50613b30929150613c9a565b600383019183908215613c5b5791602002820160005b83821115613c2657835183826101000a8154816001600160801b0302191690836001600160801b031602179055509260200192601001602081600f01049283019260010302613bdc565b8015613c595782816101000a8154906001600160801b030219169055601001602081600f01049283019260010302613c26565b505b50613b30929150613cb4565b60405180606001604052806003906020820280368337509192915050565b5b80821115613b305760008155600101613c86565b5b80821115613b3057805461ffff19168155600101613c9b565b5b80821115613b305780546001600160801b0319168155600101613cb5565b60008085851115613ce2578182fd5b83861115613cee578182fd5b505082019391909203915056fe4865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d50656e64696e6748455a3a204f4e4c595f49465f4e4f545f46554c46494c4c45444865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d50656e64696e6748455a3a204f4e4c595f49465f50524556494f55535f534c4f544865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a20434f4f5244494e41544f525f4e4f545f524547495354455245444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269643a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a2057524f4e475f414d4f554e544865726d657a41756374696f6e50726f746f636f6c3a3a6368616e676544656661756c74536c6f745365744269643a204e4f545f56414c49445f534c4f545f5345544865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2042454c4f575f4d494e494d554d4865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a7365744f757462696464696e673a204f555442494444494e475f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269642041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a6765744d696e4269644279536c6f743a2041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a20544f4b454e5f4255524e5f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c7469426964204d41584249445f475245415445525f5448414e5f4d494e4249444865726d657a41756374696f6e50726f746f636f6c3a3a6368616e676544656661756c74536c6f745365744269643a20534c4f545f444543454e5452414c495a45444865726d657a41756374696f6e50726f746f636f6c3a3a736574416c6c6f636174696f6e526174696f3a20414c4c4f434154494f4e5f524154494f5f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a6865726d657a41756374696f6e50726f746f636f6c496e697469616c697a65722047454e455349535f42454c4f575f4d494e494d414c4865726d657a41756374696f6e50726f746f636f6c3a3a736574436f6f7264696e61746f723a204e4f545f56414c49445f55524c4865726d657a41756374696f6e50726f746f636f6c3a3a736574536c6f74446561646c696e653a20475245415445525f5448414e5f424c4f434b535f5045525f534c4f54496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65644865726d657a41756374696f6e50726f746f636f6c3a3a63616e466f7267652041554354494f4e5f4e4f545f535441525445444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a204e4f545f454e4f5547485f42414c414e43454865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2041554354494f4e5f4e4f545f4f50454e4865726d657a41756374696f6e50726f746f636f6c3a3a6865726d657a41756374696f6e50726f746f636f6c496e697469616c697a657220414444524553535f305f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d48455a3a204e4f545f454e4f5547485f42414c414e4345536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a204f4e4c595f4845524d455a5f524f4c4c55504865726d657a41756374696f6e50726f746f636f6c3a3a6f6e6c79476f7665726e616e63653a204f4e4c595f474f5645524e414e43454865726d657a41756374696f6e50726f746f636f6c3a3a5f646f4269643a204249445f4d5553545f42455f4849474845524865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a2043414e4e4f545f464f5247454865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d48455a3a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c7469426964204e4f545f454e4f5547485f42414c414e43454865726d657a41756374696f6e50726f746f636f6c3a3a736574446f6e6174696f6e416464726573733a204e4f545f56414c49445f414444524553534865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269642041554354494f4e5f4e4f545f4f50454e4865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a205350454e4445525f4e4f545f455155414c5f544849534865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c746942696420434f4f5244494e41544f525f4e4f545f524547495354455245444865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204e4f545f56414c49445f43414c4c4865726d657a41756374696f6e50726f746f636f6c3a3a63616e466f7267652057524f4e475f424c4f434b4e554d4245524865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204f574e45525f4e4f545f455155414c5f53454e444552a2646970667358221220d97ee85f7cec403cb2f6b1885bb2ebcf290a8839dc016d5e84470f5c2a3c655b64736f6c634300060c0033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061023d5760003560e01c806372ca58a31161013b578063aebd6d98116100b8578063d92bdda31161007c578063d92bdda314610a82578063dfd5281b14610aa3578063e606591414610ac4578063ec29159b14610acc578063ecdae41b14610b0c5761023d565b8063aebd6d98146109c4578063b3dc7bb1146109cc578063b5f7f2f0146109f2578063bc415567146109fa578063c63de51514610a615761023d565b806383b1f6a0116100ff57806383b1f6a01461088857806387e6b6bb146108c8578063a48af096146108e8578063ac4b901214610996578063ac5f658b1461099e5761023d565b806372ca58a31461077b578063795053d3146107f857806379a135e3146108005780637c643b701461080857806382787405146108365761023d565b80634e5a5178116101c95780635cca49031161018d5780635cca49031461058f5780635e73a67f146105b55780636cbdc3df146106995780636dfe47c91461074d5780636f48e79b146107555761023d565b80634e5a51781461044457806354c03ab71461046a57806355b442e61461048e578063564e6a7114610496578063583ad0dd146104b65761023d565b806337d1bd0b1161021057806337d1bd0b1461034257806341d42c23146103685780634b93b7fa1461038e5780634cdc9c631461041d5780634da9639d146104255761023d565b80630c4da4f6146102425780630eeaf0801461026657806313de9af21461031c5780632243de471461033a575b600080fd5b61024a610b32565b604080516001600160801b039092168252519081900360200190f35b61031a6004803603604081101561027c57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156102a657600080fd5b8201836020820111156102b857600080fd5b803590602001918460018302840111600160201b831117156102d957600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610b42945050505050565b005b610324610cf0565b6040805160ff9092168252519081900360200190f35b610324610cff565b61024a6004803603602081101561035857600080fd5b50356001600160801b0316610d04565b61031a6004803603602081101561037e57600080fd5b50356001600160801b0316610ea8565b61031a600480360360808110156103a457600080fd5b6001600160801b0382358116926020810135821692604082013590921691810190608081016060820135600160201b8111156103df57600080fd5b8201836020820111156103f157600080fd5b803590602001918460018302840111600160201b8311171561041257600080fd5b509092509050611102565b61024a61140c565b61042d61141b565b6040805161ffff9092168252519081900360200190f35b61031a6004803603602081101561045a57600080fd5b50356001600160a01b031661142c565b6104726119d7565b604080516001600160a01b039092168252519081900360200190f35b61042d6119e6565b61024a600480360360208110156104ac57600080fd5b503560ff166119f0565b61031a60048036036101808110156104cd57600080fd5b6040805160c081810183526001600160801b038535811695602081013582169594810135909116938101929091610120830191906060840190600690839083908082843760009201919091525091946001600160801b0384358116956020860135909116949193509150606081019060400135600160201b81111561055157600080fd5b82018360208201111561056357600080fd5b803590602001918460018302840111600160201b8311171561058457600080fd5b509092509050611a28565b61024a600480360360208110156105a557600080fd5b50356001600160a01b0316611e0a565b61031a600480360360e08110156105cb57600080fd5b6001600160a01b0382358116926001600160801b036020820135169260408201358316926060830135811692608081013582169260a08201359092169181019060e0810160c0820135600160201b81111561062557600080fd5b82018360208201111561063757600080fd5b803590602001918460018302840111600160201b8311171561065857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611e2e945050505050565b61031a600480360360408110156106af57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156106d957600080fd5b8201836020820111156106eb57600080fd5b803590602001918460018302840111600160201b8311171561070c57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506121f0945050505050565b61031a612313565b61031a6004803603602081101561076b57600080fd5b50356001600160a01b03166124e7565b6107836125c5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156107bd5781810151838201526020016107a5565b50505050905090810190601f1680156107ea5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b610472612653565b610472612662565b61031a6004803603604081101561081e57600080fd5b506001600160801b0381358116916020013516612671565b61031a6004803603606081101561084c57600080fd5b81019080806060019060038060200260405190810160405280929190826003602002808284376000920191909152509194506128d49350505050565b6108b46004803603604081101561089e57600080fd5b506001600160a01b038135169060200135612a48565b604080519115158252519081900360200190f35b61031a600480360360208110156108de57600080fd5b503560ff16612a5d565b61090e600480360360208110156108fe57600080fd5b50356001600160a01b0316612b43565b60405180836001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561095a578181015183820152602001610942565b50505050905090810190601f1680156109875780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b61042d612bf7565b61024a600480360360208110156109b457600080fd5b50356001600160801b0316612c08565b610472612c1e565b61024a600480360360208110156109e257600080fd5b50356001600160801b0316612c2d565b610472612c67565b610a2060048036036020811015610a1057600080fd5b50356001600160801b0316612c76565b604080516001600160a01b0390961686529315156020860152911515848401526001600160801b039081166060850152166080830152519081900360a00190f35b61031a60048036036020811015610a7757600080fd5b503561ffff16612cc4565b61031a60048036036020811015610a9857600080fd5b503561ffff16612d6b565b61031a60048036036020811015610ab957600080fd5b503561ffff16612e12565b61024a612eff565b610ad4612f0d565b6040518082606080838360005b83811015610af9578181015183820152602001610ae1565b5050505090500191505060405180910390f35b61024a60048036036020811015610b2257600080fd5b50356001600160a01b0316612f6f565b6000610b3d43612c2d565b905090565b604080516000815260208082018084528251902084519093859301918291908401908083835b60208310610b875780518252601f199092019160209182019101610b68565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001201415610bff5760405162461bcd60e51b81526004018080602001828103825260348152602001806140af6034913960400191505060405180910390fd5b33600090815260416020908152604090912080546001600160a01b0319166001600160a01b0385161781558251610c3e92600190920191840190613ab6565b50816001600160a01b0316336001600160a01b03167f5246b2ac9ee77efe2e64af6df00055d97e2d6e1b277f5a8d17ba5bca1a573da0836040518080602001828103825283818151815260200191508051906020019080838360005b83811015610cb2578181015183820152602001610c9a565b50505050905090810190601f168015610cdf5780820380516001836020036101000a031916815260200191505b509250505060405180910390a35050565b603e5462010000900460ff1690565b602881565b603c54600090600160801b900461ffff16610d1d610b32565b016001600160801b0316826001600160801b031611610d6d5760405162461bcd60e51b8152600401808060200182810382526036815260200180613f356036913960400191505060405180910390fd5b6000610d7883612c08565b6001600160801b038085166000908152603f60205260409020600101549192501615610e1257603e546001600160801b038085166000908152603f6020526040902060010154610e0d92610de99261271092610dda9291169061ffff16612f8a565b6001600160801b031690613004565b6001600160801b038086166000908152603f60205260409020600101541690613046565b610ea1565b603e54610ea190610e659061271090610dda9061ffff1660396001600160801b03871660068110610e3f57fe5b60028104919091015460019091166010026101000a90046001600160801b031690612f8a565b6039836001600160801b031660068110610e7b57fe5b60028104919091015460019091166010026101000a90046001600160801b031690613046565b9392505050565b610eb0610b32565b6001600160801b0316816001600160801b031610610eff5760405162461bcd60e51b815260040180806020018281038252603d815260200180613d39603d913960400191505060405180910390fd5b6001600160801b0381166000908152603f6020526040902054600160a01b900460ff1615610f5e5760405162461bcd60e51b815260040180806020018281038252603d815260200180613cfc603d913960400191505060405180910390fd5b6001600160801b038082166000908152603f60205260408120600101549091600160801b9091041615610fb5576001600160801b038083166000908152603f6020526040902060010154600160801b900416610ff3565b6039610fc083612c08565b6001600160801b031660068110610fd357fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b038381166000908152603f60205260409020600101549192508083169116106110545760405162461bcd60e51b815260040180806020018281038252603d815260200180613cfc603d913960400191505060405180910390fd5b6001600160801b038083166000908152603f60209081526040808320600181018054868816600160801b029087161790819055815460ff60a01b1916600160a01b17918290556001600160a01b03909116845291819052909120546110bd929081169116613046565b6001600160801b039283166000908152603f60209081526040808320546001600160a01b0316835290819052902080546001600160801b031916919093161790915550565b336000908152604160205260409020546001600160a01b03166111565760405162461bcd60e51b815260040180806020018281038252603d815260200180613d76603d913960400191505060405180910390fd5b603c54600160801b900461ffff1661116c610b32565b016001600160801b0316846001600160801b0316116111bc5760405162461bcd60e51b81526004018080602001828103825260318152602001806144686031913960400191505060405180910390fd5b6111c584610d04565b6001600160801b0316836001600160801b031610156112155760405162461bcd60e51b8152600401808060200182810382526030815260200180613e5e6030913960400191505060405180910390fd5b603c5461ffff600160901b8204811691600160801b900416611235610b32565b01016001600160801b0316846001600160801b031611156112875760405162461bcd60e51b81526004018080602001828103825260338152602001806141bd6033913960400191505060405180910390fd5b80156112a1576112a1856001600160801b031683836130ac565b603354604080516323b872dd60e01b81523360048201523060248201526001600160801b038816604482015290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b15801561130357600080fd5b505af1158015611317573d6000803e3d6000fd5b505050506040513d602081101561132d57600080fd5b505161136a5760405162461bcd60e51b8152600401808060200182810382526038815260200180613e8e6038913960400191505060405180910390fd5b3360009081526040602081905290205461138d906001600160801b031686613046565b33600090815260406020819052902080546001600160801b0319166001600160801b039283161790819055848216911610156113fa5760405162461bcd60e51b81526004018080602001828103825260358152602001806141886035913960400191505060405180910390fd5b61140584843361334b565b5050505050565b603c546001600160801b031681565b603c54600160801b900461ffff1690565b6034546001600160a01b031633146114755760405162461bcd60e51b815260040180806020018281038252603081526020018061428f6030913960400191505060405180910390fd5b61147f814361352b565b6114ba5760405162461bcd60e51b815260040180806020018281038252602a815260200180614326602a913960400191505060405180910390fd5b60006114c4610b32565b6001600160801b0381166000908152603f6020526040902054909150600160a81b900460ff1661157f57603c5460009061153490611524906001600160801b03908116906115159086166028612f8a565b6001600160801b031690613046565b6001600160801b034316906137df565b603e5490915062010000900460ff166001600160801b038216101561157d576001600160801b0382166000908152603f60205260409020805460ff60a81b1916600160a81b1790555b505b6001600160801b0381166000908152603f6020526040902054600160a01b900460ff16611994576001600160801b038082166000908152603f60205260409020805460ff60a01b1916600160a01b178155600101541615611994576001600160801b038082166000908152603f60205260408120600101549091600160801b9091041615611631576001600160801b038083166000908152603f6020526040902060010154600160801b90041661166f565b603961163c83612c08565b6001600160801b03166006811061164f57fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b038381166000908152603f602052604090206001015491925080831691161015611727576001600160801b038083166000908152603f60209081526040808320600181015490546001600160a01b0316845291819052909120546116de929081169116613046565b6001600160801b038381166000908152603f60209081526040808320546001600160a01b0316835290819052902080546001600160801b03191692909116919091179055611992565b6001600160801b038281166000908152603f6020526040812060010154603d549216916117619061271090610dda90859061ffff16612f8a565b603d549091506000906117909061271090610dda906001600160801b0387169062010000900461ffff16612f8a565b603d549091506000906117c09061271090610dda906001600160801b03881690600160201b900461ffff16612f8a565b60335460408051630852cd8d60e31b81526001600160801b038716600482015290519293506001600160a01b03909116916342966c68916024808201926020929091908290030181600087803b15801561181957600080fd5b505af115801561182d573d6000803e3d6000fd5b505050506040513d602081101561184357600080fd5b50516118805760405162461bcd60e51b815260040180806020018281038252602f815260200180613f6b602f913960400191505060405180910390fd5b6036546001600160a01b03166000908152604060208190529020546118ae906001600160801b031683613046565b6036546001600160a01b0390811660009081526040602081905280822080546001600160801b0319166001600160801b03958616179055603554909216815220546118fa911682613046565b6035546001600160a01b0390811660009081526040602081815281832080546001600160801b0319166001600160801b039687161790558a8516808452603f82529282902054825189871681528887169281019290925294861681830152905191938b84169316917fd64ebb43f4c2b91022b97389834432f1027ef55586129ba05a3a3065b2304f05916060908290030190a4505050505b505b6040516001600160801b038216906001600160a01b038416907f7cae662d4cfa9d9c5575c65f0cc41a858c51ca14ebcbd02a802a62376c3ad23890600090a35050565b6036546001600160a01b031690565b603e5461ffff1690565b600060398260ff1660068110611a0257fe5b600291828204019190066010029054906101000a90046001600160801b03169050919050565b603c54600160801b900461ffff16611a3e610b32565b016001600160801b0316876001600160801b031611611a8e5760405162461bcd60e51b8152600401808060200182810382526035815260200180613f006035913960400191505060405180910390fd5b603c5461ffff600160901b8204811691600160801b900416611aae610b32565b01016001600160801b0316866001600160801b03161115611b005760405162461bcd60e51b81526004018080602001828103825260378152602001806143fb6037913960400191505060405180910390fd5b826001600160801b0316846001600160801b03161015611b515760405162461bcd60e51b8152600401808060200182810382526041815260200180613f9a6041913960600191505060405180910390fd5b336000908152604160205260409020546001600160a01b0316611ba55760405162461bcd60e51b81526004018080602001828103825260418152602001806144996041913960600191505060405180910390fd5b8015611bbf57611bbf886001600160801b031683836130ac565b603354604080516323b872dd60e01b81523360048201523060248201526001600160801b038b16604482015290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015611c2157600080fd5b505af1158015611c35573d6000803e3d6000fd5b505050506040513d6020811015611c4b57600080fd5b5051611c885760405162461bcd60e51b815260040180806020018281038252603d815260200180613db3603d913960400191505060405180910390fd5b33600090815260406020819052902054611cab906001600160801b031689613046565b33600090815260406020819052812080546001600160801b0319166001600160801b039390931692909217909155875b876001600160801b0316816001600160801b031611611dfe576000611cff82610d04565b9050856001600160801b0316816001600160801b031611611d2257859250611d68565b856001600160801b0316816001600160801b0316118015611d555750866001600160801b0316816001600160801b031611155b15611d6257809250611d68565b50611df6565b87611d7283612c08565b6001600160801b031660068110611d8557fe5b602002015115611df457336000908152604060208190529020546001600160801b0380851691161015611de95760405162461bcd60e51b81526004018080602001828103825260398152602001806143866039913960400191505060405180910390fd5b611df482843361334b565b505b600101611cdb565b50505050505050505050565b6001600160a01b03166000908152604060208190529020546001600160801b031690565b600054610100900460ff1680611e475750611e47613821565b80611e55575060005460ff16155b611e905760405162461bcd60e51b815260040180806020018281038252602e815260200180614127602e913960400191505060405180910390fd5b600054610100900460ff16158015611ebb576000805460ff1961ff0019909116610100171660011790555b611ec3613827565b6001600160a01b038616611f085760405162461bcd60e51b815260040180806020018281038252604b8152602001806141f0604b913960600191505060405180910390fd5b603e80546103e861ffff199091161762ff0000191662140000179055603c805461ffff60801b1916600160811b1761ffff60901b1916608760951b17905560408051606081018252610fa080825260208201526107d091810191909152611f7390603d906003613b34565b506040805160c08101825269d3c21bcecceda100000080825260208201819052918101829052606081018290526080810182905260a0810191909152611fbd906039906006613bc6565b5043876001600160801b031610156120065760405162461bcd60e51b815260040180806020018281038252604d815260200180614062604d913960600191505060405180910390fd5b603380546001600160a01b03199081166001600160a01b038b811691909117909255603c80546001600160801b0319166001600160801b038b1617905560348054821689841617905560358054821688841617905560368054821687841617905560378054909116918516919091179055815161208a906038906020850190613ab6565b50603e54603c54604080516001600160a01b0388811682528716602082015261ffff808516606083018190526201000090950460ff1660808301819052600160801b8504821660a08401819052600160901b90950490911660c083018190527f9717e4e04c13817c600463a7a450110c754fd78758cdd538603f30528a24ce4b958a958a958a959294939192603d918101610140820183600060e085015b82829054906101000a900461ffff1661ffff16815260200190600201906020826001010492830192600103820291508084116121285750505082810382528851815288516020918201918a019080838360005b8381101561219357818101518382015260200161217b565b50505050905090810190601f1680156121c05780820380516001836020036101000a031916815260200191505b50995050505050505050505060405180910390a180156121e6576000805461ff00191690555b5050505050505050565b6035546001600160a01b031633146122395760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603780546001600160a01b0319166001600160a01b0384161790558051612267906038906020840190613ab6565b5060375460408051602080825284518183015284516001600160a01b03909416937f0487eab4c1da34bf653268e33bee8bfec7dacfd6f3226047197ebf872293cfd6938693928392918301919085019080838360005b838110156122d55781810151838201526020016122bd565b50505050905090810190601f1680156123025780820380516001836020036101000a031916815260200191505b509250505060405180910390a25050565b6002600154141561236b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155600061237b33611e0a565b90506000816001600160801b0316116123c55760405162461bcd60e51b815260040180806020018281038252603381526020018061423b6033913960400191505060405180910390fd5b3360008181526040602081815281832080546001600160801b0319169055603354825163a9059cbb60e01b815260048101959095526001600160801b038616602486015291516001600160a01b039092169363a9059cbb93604480830194928390030190829087803b15801561243a57600080fd5b505af115801561244e573d6000803e3d6000fd5b505050506040513d602081101561246457600080fd5b50516124a15760405162461bcd60e51b81526004018080602001828103825260368152602001806143506036913960400191505060405180910390fd5b604080516001600160801b0383168152905133917f199ef0cb54d2b296ff6eaec2721bacf0ca3fd8344a43f5bdf4548b34dfa2594f919081900360200190a25060018055565b6035546001600160a01b031633146125305760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b6001600160a01b0381166125755760405162461bcd60e51b815260040180806020018281038252603c8152602001806143bf603c913960400191505060405180910390fd5b603680546001600160a01b0319166001600160a01b0383811691909117918290556040519116907fa62863cbad1647a2855e9cd39d04fa6dfd32e1b9cfaff1aaf6523f4aaafeccd790600090a250565b6038805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561264b5780601f106126205761010080835404028352916020019161264b565b820191906000526020600020905b81548152906001019060200180831161262e57829003601f168201915b505050505081565b6035546001600160a01b031681565b6033546001600160a01b031681565b6035546001600160a01b031633146126ba5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b6006826001600160801b0316106127025760405162461bcd60e51b8152600401808060200182810382526042815260200180613e1c6042913960600191505060405180910390fd5b6039826001600160801b03166006811061271857fe5b60028104919091015460019091166010026101000a90046001600160801b03166127735760405162461bcd60e51b8152600401808060200182810382526042815260200180613fdb6042913960600191505060405180910390fd5b600061277d610b32565b9050805b603c54600160801b900461ffff1682016001600160801b0390811690821611612837576001600160801b038082166000908152603f6020526040902060010154600160801b90041661282f5760396127d882612c08565b6001600160801b0316600681106127eb57fe5b6002810491909101546001600160801b038381166000908152603f60205260409020600190810180548316919094166010026101000a90920416600160801b021790555b600101612781565b50816039846001600160801b03166006811061284f57fe5b600291828204019190066010026101000a8154816001600160801b0302191690836001600160801b031602179055507fa922aa010d1ff8e70b2aa9247d891836795c3d3ba2a543c37c91a44dc4a50172838360405180836001600160801b03168152602001826001600160801b031681526020019250505060405180910390a1505050565b6035546001600160a01b0316331461291d5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b805161271061ffff909116118015906129435750612710816001602002015161ffff1611155b801561295c5750612710816002602002015161ffff1611155b80156129865750806002602002015181600160200201518260006020020151010161ffff16612710145b6129c15760405162461bcd60e51b815260040180806020018281038252604581526020018061401d6045913960600191505060405180910390fd5b6129ce603d826003613b34565b506040517f0bb59eceb12f1bdb63e4a7d57c70d6473fefd7c3f51af5a3604f7e97197073e490603d9060608101826000835b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411612a00579050505091505060405180910390a150565b6000612a54838361352b565b90505b92915050565b6035546001600160a01b03163314612aa65760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b602860ff82161115612ae95760405162461bcd60e51b81526004018080602001828103825260448152602001806140e36044913960600191505060405180910390fd5b603e805460ff8084166201000090810262ff0000199093169290921792839055604080519290930416815290517f4a0d90b611c15e02dbf23b10f35b936cf2c77665f8c77822d3eca131f9d986d39181900360200190a150565b6041602090815260009182526040918290208054600180830180548651600261010094831615949094026000190190911692909204601f81018690048602830186019096528582526001600160a01b03909216949293909290830182828015612bed5780601f10612bc257610100808354040283529160200191612bed565b820191906000526020600020905b815481529060010190602001808311612bd057829003601f168201915b5050505050905082565b603c54600160901b900461ffff1690565b6000612a576001600160801b03831660066138cd565b6034546001600160a01b031681565b603c546000906001600160801b039081169083161015612c4e576000612a57565b50603c5460286001600160801b03918216909203160490565b6037546001600160a01b031690565b603f60205260009081526040902080546001909101546001600160a01b0382169160ff600160a01b8204811692600160a81b90920416906001600160801b0380821691600160801b90041685565b6035546001600160a01b03163314612d0d5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603c805461ffff808416600160901b90810261ffff60901b199093169290921792839055604080519290930416815290517f3da0492dea7298351bc14d1c0699905fd0657c33487449751af50fc0c8b593f19181900360200190a150565b6035546001600160a01b03163314612db45760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b603c805461ffff808416600160801b90810261ffff60801b199093169290921792839055604080519290930416815290517fc78051d3757db196b1e445f3a9a1380944518c69b5d7922ec747c54f0340a4ea9181900360200190a150565b6035546001600160a01b03163314612e5b5760405162461bcd60e51b81526004018080602001828103825260368152602001806142bf6036913960400191505060405180910390fd5b60018161ffff16118015612e7457506127108161ffff16105b612eaf5760405162461bcd60e51b815260040180806020018281038252603a815260200180613ec6603a913960400191505060405180910390fd5b603e805461ffff191661ffff838116919091179182905560408051929091168252517fd3748b8c326e93d12af934fbf87471e315a89bc3f7b8222343acf0210edf248e916020908290030190a150565b69d3c21bcecceda100000081565b612f15613c67565b60408051606081019182905290603d90600390826000855b82829054906101000a900461ffff1661ffff1681526020019060020190602082600101049283019260010382029150808411612f2d5790505050505050905090565b6040602081905260009182529020546001600160801b031681565b60006001600160801b038316612fa257506000612a57565b8282026001600160801b038084169080861690831681612fbe57fe5b046001600160801b031614612a545760405162461bcd60e51b815260040180806020018281038252602181526020018061426e6021913960400191505060405180910390fd5b6000612a5483836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f00000000000081525061390f565b60008282016001600160801b038085169082161015612a54576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000828260208110156130be57600080fd5b50356001600160e01b031916905063d505accf60e01b81146131115760405162461bcd60e51b815260040180806020018281038252602e8152602001806144da602e913960400191505060405180910390fd5b6000808080808080613126896004818d613cd3565b60e081101561313457600080fd5b506001600160a01b038135811698506020820135169650604081013595506060810135945060ff608082013516935060a0810135925060c0013590503387146131ae5760405162461bcd60e51b81526004018080602001828103825260368152602001806145396036913960400191505060405180910390fd5b6001600160a01b03861630146131f55760405162461bcd60e51b81526004018080602001828103825260368152602001806144326036913960400191505060405180910390fd5b8a85146132335760405162461bcd60e51b815260040180806020018281038252602c815260200180613df0602c913960400191505060405180910390fd5b603354604080516001600160a01b038a811660248301528981166044830152606482018990526084820188905260ff871660a483015260c4820186905260e48083018690528351808403909101815261010490920183526020820180516001600160e01b031663d505accf60e01b178152925182519190941693919282918083835b602083106132d45780518252601f1990920191602091820191016132b5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613336576040519150601f19603f3d011682016040523d82523d6000602084013e61333b565b606091505b5050505050505050505050505050565b6001600160801b038084166000908152603f6020526040902080546001909101546001600160a01b039091169190811690841681106133bb5760405162461bcd60e51b81526004018080602001828103825260318152602001806142f56031913960400191505060405180910390fd5b6001600160a01b0383166000908152604060208190529020546133e7906001600160801b0316856137df565b6001600160a01b0384811660008181526040602081815281832080546001600160801b03199081166001600160801b03988916179091558b87168452603f909152912080546001600160a01b031916909217825560019190910180549091169287169290921790915582161580159061346857506001600160801b03811615155b156134d0576001600160a01b038216600090815260406020819052902054613499906001600160801b031682613046565b6001600160a01b038316600090815260406020819052902080546001600160801b0319166001600160801b03929092169190911790555b826001600160a01b0316856001600160801b03167fd48e8329cdb2fb109b4fe445d7b681a74b256bff16e6f7f33b9d4fbe9038e4338660405180826001600160801b0316815260200191505060405180910390a35050505050565b6000600160801b821061356f5760405162461bcd60e51b81526004018080602001828103825260318152602001806145086031913960400191505060405180910390fd5b603c546001600160801b03168210156135b95760405162461bcd60e51b81526004018080602001828103825260338152602001806141556033913960400191505060405180910390fd5b60006135c483612c2d565b603c549091506000906135fe906135ee906001600160801b03908116906115159086166028612f8a565b6001600160801b038616906137df565b6001600160801b038084166000908152603f602052604081206001015492935091600160801b90041615613656576001600160801b038084166000908152603f6020526040902060010154600160801b900416613694565b603961366184612c08565b6001600160801b03166006811061367457fe5b600291828204019190066010029054906101000a90046001600160801b03165b6001600160801b0384166000908152603f6020526040902054909150600160a81b900460ff161580156136db5750603e5462010000900460ff166001600160801b03831610155b156136ec5760019350505050612a57565b6001600160801b0383166000908152603f60209081526040808320546001600160a01b039081168452604190925290912054811690871614801561375057506001600160801b038381166000908152603f6020526040902060010154818316911610155b156137615760019350505050612a57565b6037546001600160a01b0387811691161480156137c257506001600160801b038381166000908152603f6020526040902060010154818316911610806137c257506001600160801b038084166000908152603f602052604090206001015416155b156137d35760019350505050612a57565b60009350505050612a57565b6000612a5483836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f7700008152506139cc565b303b1590565b600054610100900460ff16806138405750613840613821565b8061384e575060005460ff16155b6138895760405162461bcd60e51b815260040180806020018281038252602e815260200180614127602e913960400191505060405180910390fd5b600054610100900460ff161580156138b4576000805460ff1961ff0019909116610100171660011790555b6001805580156138ca576000805461ff00191690555b50565b6000612a5483836040518060400160405280601881526020017f536166654d6174683a206d6f64756c6f206279207a65726f0000000000000000815250613a39565b6000816001600160801b0384166139a45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613969578181015183820152602001613951565b50505050905090810190601f1680156139965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b506000836001600160801b0316856001600160801b0316816139c257fe5b0495945050505050565b6000836001600160801b0316836001600160801b031611158290613a315760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613969578181015183820152602001613951565b505050900390565b6000816001600160801b038416613a915760405162461bcd60e51b8152602060048201818152835160248401528351909283926044909101919085019080838360008315613969578181015183820152602001613951565b50826001600160801b0316846001600160801b031681613aad57fe5b06949350505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10613af757805160ff1916838001178555613b24565b82800160010185558215613b24579182015b82811115613b24578251825591602001919060010190613b09565b50613b30929150613c85565b5090565b600183019183908215613bba5791602002820160005b83821115613b8a57835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302613b4a565b8015613bb85782816101000a81549061ffff0219169055600201602081600101049283019260010302613b8a565b505b50613b30929150613c9a565b600383019183908215613c5b5791602002820160005b83821115613c2657835183826101000a8154816001600160801b0302191690836001600160801b031602179055509260200192601001602081600f01049283019260010302613bdc565b8015613c595782816101000a8154906001600160801b030219169055601001602081600f01049283019260010302613c26565b505b50613b30929150613cb4565b60405180606001604052806003906020820280368337509192915050565b5b80821115613b305760008155600101613c86565b5b80821115613b3057805461ffff19168155600101613c9b565b5b80821115613b305780546001600160801b0319168155600101613cb5565b60008085851115613ce2578182fd5b83861115613cee578182fd5b505082019391909203915056fe4865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d50656e64696e6748455a3a204f4e4c595f49465f4e4f545f46554c46494c4c45444865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d50656e64696e6748455a3a204f4e4c595f49465f50524556494f55535f534c4f544865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a20434f4f5244494e41544f525f4e4f545f524547495354455245444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269643a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a2057524f4e475f414d4f554e544865726d657a41756374696f6e50726f746f636f6c3a3a6368616e676544656661756c74536c6f745365744269643a204e4f545f56414c49445f534c4f545f5345544865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2042454c4f575f4d494e494d554d4865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a7365744f757462696464696e673a204f555442494444494e475f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269642041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a6765744d696e4269644279536c6f743a2041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a20544f4b454e5f4255524e5f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c7469426964204d41584249445f475245415445525f5448414e5f4d494e4249444865726d657a41756374696f6e50726f746f636f6c3a3a6368616e676544656661756c74536c6f745365744269643a20534c4f545f444543454e5452414c495a45444865726d657a41756374696f6e50726f746f636f6c3a3a736574416c6c6f636174696f6e526174696f3a20414c4c4f434154494f4e5f524154494f5f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a6865726d657a41756374696f6e50726f746f636f6c496e697469616c697a65722047454e455349535f42454c4f575f4d494e494d414c4865726d657a41756374696f6e50726f746f636f6c3a3a736574436f6f7264696e61746f723a204e4f545f56414c49445f55524c4865726d657a41756374696f6e50726f746f636f6c3a3a736574536c6f74446561646c696e653a20475245415445525f5448414e5f424c4f434b535f5045525f534c4f54496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a65644865726d657a41756374696f6e50726f746f636f6c3a3a63616e466f7267652041554354494f4e5f4e4f545f535441525445444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a204e4f545f454e4f5547485f42414c414e43454865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2041554354494f4e5f4e4f545f4f50454e4865726d657a41756374696f6e50726f746f636f6c3a3a6865726d657a41756374696f6e50726f746f636f6c496e697469616c697a657220414444524553535f305f4e4f545f56414c49444865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d48455a3a204e4f545f454e4f5547485f42414c414e4345536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f774865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a204f4e4c595f4845524d455a5f524f4c4c55504865726d657a41756374696f6e50726f746f636f6c3a3a6f6e6c79476f7665726e616e63653a204f4e4c595f474f5645524e414e43454865726d657a41756374696f6e50726f746f636f6c3a3a5f646f4269643a204249445f4d5553545f42455f4849474845524865726d657a41756374696f6e50726f746f636f6c3a3a666f7267653a2043414e4e4f545f464f5247454865726d657a41756374696f6e50726f746f636f6c3a3a636c61696d48455a3a20544f4b454e5f5452414e534645525f4641494c45444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c7469426964204e4f545f454e4f5547485f42414c414e43454865726d657a41756374696f6e50726f746f636f6c3a3a736574446f6e6174696f6e416464726573733a204e4f545f56414c49445f414444524553534865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c74694269642041554354494f4e5f4e4f545f4f50454e4865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a205350454e4445525f4e4f545f455155414c5f544849534865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734269643a2041554354494f4e5f434c4f5345444865726d657a41756374696f6e50726f746f636f6c3a3a70726f636573734d756c746942696420434f4f5244494e41544f525f4e4f545f524547495354455245444865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204e4f545f56414c49445f43414c4c4865726d657a41756374696f6e50726f746f636f6c3a3a63616e466f7267652057524f4e475f424c4f434b4e554d4245524865726d657a41756374696f6e50726f746f636f6c3a3a5f7065726d69743a204f574e45525f4e4f545f455155414c5f53454e444552a2646970667358221220d97ee85f7cec403cb2f6b1885bb2ebcf290a8839dc016d5e84470f5c2a3c655b64736f6c634300060c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/eth/contracts/abi/WithdrawalDelayer.json b/eth/contracts/abi/WithdrawalDelayer.json new file mode 100644 index 000000000..af49bb770 --- /dev/null +++ b/eth/contracts/abi/WithdrawalDelayer.json @@ -0,0 +1,501 @@ +{ + "_format": "hh-sol-artifact-1", + "contractName": "WithdrawalDelayer", + "sourceName": "contracts/withdrawalDelayer/WithdrawalDelayer.sol", + "abi": [ + { + "inputs": [ + { + "internalType": "uint64", + "name": "_initialWithdrawalDelay", + "type": "uint64" + }, + { + "internalType": "address", + "name": "_initialHermezRollup", + "type": "address" + }, + { + "internalType": "address", + "name": "_initialHermezGovernanceAddress", + "type": "address" + }, + { + "internalType": "address payable", + "name": "_initialEmergencyCouncil", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint192", + "name": "amount", + "type": "uint192" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "depositTimestamp", + "type": "uint64" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "EmergencyModeEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "who", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "EscapeHatchWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "initialWithdrawalDelay", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "address", + "name": "initialHermezGovernanceAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "initialEmergencyCouncil", + "type": "address" + } + ], + "name": "InitializeWithdrawalDelayerEvent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newEmergencyCouncil", + "type": "address" + } + ], + "name": "NewEmergencyCouncil", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newHermezGovernanceAddress", + "type": "address" + } + ], + "name": "NewHermezGovernanceAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint64", + "name": "withdrawalDelay", + "type": "uint64" + } + ], + "name": "NewWithdrawalDelay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint192", + "name": "amount", + "type": "uint192" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "MAX_EMERGENCY_MODE_TIME", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_WITHDRAWAL_DELAY", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64", + "name": "_newWithdrawalDelay", + "type": "uint64" + } + ], + "name": "changeWithdrawalDelay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimEmergencyCouncil", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint192", + "name": "_amount", + "type": "uint192" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "depositInfo", + "outputs": [ + { + "internalType": "uint192", + "name": "", + "type": "uint192" + }, + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "deposits", + "outputs": [ + { + "internalType": "uint192", + "name": "amount", + "type": "uint192" + }, + { + "internalType": "uint64", + "name": "depositTimestamp", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "enableEmergencyMode", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "escapeHatchWithdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getEmergencyCouncil", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getEmergencyModeStartingTime", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getHermezGovernanceAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getWithdrawalDelay", + "outputs": [ + { + "internalType": "uint64", + "name": "", + "type": "uint64" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "hermezRollupAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isEmergencyMode", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingEmergencyCouncil", + "outputs": [ + { + "internalType": "address payable", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingGovernance", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "newEmergencyCouncil", + "type": "address" + } + ], + "name": "transferEmergencyCouncil", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGovernance", + "type": "address" + } + ], + "name": "transferGovernance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_token", + "type": "address" + } + ], + "name": "withdrawal", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "bytecode": "0x608060405234801561001057600080fd5b50604051611b70380380611b708339818101604052608081101561003357600080fd5b508051602082015160408301516060909301516001600055919290916001600160a01b0383166100945760405162461bcd60e51b8152600401808060200182810382526043815260200180611b2d6043913960600191505060405180910390fd5b600180546001600160401b0386166001600160401b03199091168117909155600680546001600160a01b038087166001600160a01b0319928316179092556002805486841690831681179091556005805460ff60a01b19948716931683179390931690925560408051938452602084019290925282820152517f8b81dca4c96ae06989fa8aa1baa4ccc05dfb42e0948c7d5b7505b68ccde41eec9181900360600190a1505050506119e38061014a6000396000f3fe60806040526004361061012a5760003560e01c80637fd6b102116100ab578063ca79033f1161006f578063ca79033f1461036a578063cfc0b6411461037f578063d38bfff4146103bf578063db2a1a81146103f2578063de35f28214610425578063f39c38a0146104605761012a565b80637fd6b102146102d357806399ef11c514610316578063a238f9df1461032b578063b4b8e39d14610340578063c5b1c7d0146103555761012a565b80633d4dff7b116100f25780633d4dff7b14610204578063493b0170146102595780635d36b19014610294578063668cdd67146102a957806367fa2403146102be5761012a565b8063031609401461012f5780630b21d430146101605780630e670af5146101915780630fd266d7146101c657806320a194b8146101db575b600080fd5b34801561013b57600080fd5b50610144610475565b604080516001600160401b039092168252519081900360200190f35b34801561016c57600080fd5b50610175610484565b604080516001600160a01b039092168252519081900360200190f35b34801561019d57600080fd5b506101c4600480360360208110156101b457600080fd5b50356001600160401b0316610493565b005b3480156101d257600080fd5b50610175610597565b3480156101e757600080fd5b506101f06105a6565b604080519115158252519081900360200190f35b34801561021057600080fd5b5061022e6004803603602081101561022757600080fd5b50356105b6565b604080516001600160c01b0390931683526001600160401b0390911660208301528051918290030190f35b34801561026557600080fd5b5061022e6004803603604081101561027c57600080fd5b506001600160a01b03813581169160200135166105e3565b3480156102a057600080fd5b506101c4610674565b3480156102b557600080fd5b5061014461071e565b3480156102ca57600080fd5b50610175610734565b3480156102df57600080fd5b506101c4600480360360608110156102f657600080fd5b506001600160a01b03813581169160208101359091169060400135610743565b34801561032257600080fd5b5061017561095a565b34801561033757600080fd5b50610144610969565b34801561034c57600080fd5b50610144610970565b34801561036157600080fd5b506101c4610977565b34801561037657600080fd5b506101c4610a73565b6101c46004803603606081101561039557600080fd5b5080356001600160a01b0390811691602081013590911690604001356001600160c01b0316610b1d565b3480156103cb57600080fd5b506101c4600480360360208110156103e257600080fd5b50356001600160a01b0316610e99565b3480156103fe57600080fd5b506101c46004803603602081101561041557600080fd5b50356001600160a01b0316610f04565b34801561043157600080fd5b506101c46004803603604081101561044857600080fd5b506001600160a01b0381358116916020013516610f6f565b34801561046c57600080fd5b506101756111bd565b6001546001600160401b031690565b6002546001600160a01b031690565b6002546001600160a01b03163314806104b657506006546001600160a01b031633145b6104f15760405162461bcd60e51b81526004018080602001828103825260438152602001806117306043913960600191505060405180910390fd5b621275006001600160401b038216111561053c5760405162461bcd60e51b81526004018080602001828103825260468152602001806118a56046913960600191505060405180910390fd5b6001805467ffffffffffffffff19166001600160401b03838116919091179182905560408051929091168252517f6b3670ab51e04a9da086741e5fd1eb36ffaf1d661a15330c528e1f3e0c8722d7916020908290030190a150565b6006546001600160a01b031681565b600554600160a01b900460ff1690565b6007602052600090815260409020546001600160c01b03811690600160c01b90046001600160401b031682565b6000806105ee6114f4565b505060408051606094851b6001600160601b03199081166020808401919091529490951b90941660348501528051808503602801815260488501808352815191850191909120600090815260079094529281902060888501909152546001600160c01b03811692839052600160c01b90046001600160401b031660689093018390525091565b6003546001600160a01b031633146106bd5760405162461bcd60e51b815260040180806020018281038252603b8152602001806116bf603b913960400191505060405180910390fd5b60038054600280546001600160a01b038084166001600160a01b03199283161792839055921690925560408051929091168252517f3bf02437d5cd40067085d9dac2c3cdcbef0a449d98a259a40d9c24380aca81bf916020908290030190a1565b600154600160401b90046001600160401b031690565b6004546001600160a01b031681565b6002600054141561079b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055600554600160a01b900460ff166107e85760405162461bcd60e51b81526004018080602001828103825260348152602001806115e66034913960400191505060405180910390fd5b6005546001600160a01b031633148061080b57506002546001600160a01b031633145b6108465760405162461bcd60e51b815260040180806020018281038252603981526020018061180e6039913960400191505060405180910390fd5b6005546001600160a01b03163314801561087157506002546005546001600160a01b03908116911614155b156108d3576001546001600160401b03600160401b909104811662eff1000181164290911610156108d35760405162461bcd60e51b81526004018080602001828103825260448152602001806116496044913960600191505060405180910390fd5b6001600160a01b0382166108f0576108eb83826111cc565b6108fb565b6108fb828483611261565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fde200220117ba95c9a6c4a1a13bb06b0b7be90faa85c8fb4576630119f891693846040518082815260200191505060405180910390a45050600160005550565b6005546001600160a01b031690565b6212750081565b62eff10081565b6002546001600160a01b031633146109c05760405162461bcd60e51b81526004018080602001828103825260378152602001806119206037913960400191505060405180910390fd5b600554600160a01b900460ff1615610a095760405162461bcd60e51b81526004018080602001828103825260378152602001806115af6037913960400191505060405180910390fd5b6005805460ff60a01b1916600160a01b179055600180546001600160401b034216600160401b026fffffffffffffffff0000000000000000199091161790556040517f2064d51aa5a8bd67928c7675e267e05c67ad5adf7c9098d0a602d01f36fda9c590600090a1565b6004546001600160a01b03163314610abc5760405162461bcd60e51b81526004018080602001828103825260418152602001806115346041913960600191505060405180910390fd5b60048054600580546001600160a01b038084166001600160a01b03199283161792839055921690925560408051929091168252517fcc267667d474ef34ee2de2d060e7c8b2c7295cefa22e57fd7049e22b5fdb5396916020908290030190a1565b60026000541415610b75576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556006546001600160a01b03163314610bc35760405162461bcd60e51b81526004018080602001828103825260278152602001806117b66027913960400191505060405180910390fd5b3415610c5b576001600160a01b03821615610c0f5760405162461bcd60e51b815260040180806020018281038252602f81526020018061161a602f913960400191505060405180910390fd5b34816001600160c01b031614610c565760405162461bcd60e51b815260040180806020018281038252602881526020018061150c6028913960400191505060405180910390fd5b610e84565b60065460408051636eb1769f60e11b81526001600160a01b03928316600482015230602482015290516001600160c01b0384169285169163dd62ed3e916044808301926020929190829003018186803b158015610cb757600080fd5b505afa158015610ccb573d6000803e3d6000fd5b505050506040513d6020811015610ce157600080fd5b50511015610d205760405162461bcd60e51b81526004018080602001828103825260308152602001806119576030913960400191505060405180910390fd5b600654604080516001600160a01b0392831660248201523060448201526001600160c01b03841660648083019190915282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b178152915181516000946060949088169392918291908083835b60208310610db15780518252601f199092019160209182019101610d92565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610e13576040519150601f19603f3d011682016040523d82523d6000602084013e610e18565b606091505b5091509150818015610e46575080511580610e465750808060200190516020811015610e4357600080fd5b50515b610e815760405162461bcd60e51b81526004018080602001828103825260318152602001806117dd6031913960400191505060405180910390fd5b50505b610e8f8383836113b5565b5050600160005550565b6002546001600160a01b03163314610ee25760405162461bcd60e51b81526004018080602001828103825260368152602001806116fa6036913960400191505060405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b81526004018080602001828103825260438152602001806117736043913960600191505060405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b60026000541415610fc7576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055600554600160a01b900460ff16156110155760405162461bcd60e51b815260040180806020018281038252602a815260200180611847602a913960400191505060405180910390fd5b60408051606084811b6001600160601b03199081166020808501919091529185901b166034830152825180830360280181526048909201835281519181019190912060008181526007909252919020546001600160c01b0316806110aa5760405162461bcd60e51b81526004018080602001828103825260278152602001806119876027913960400191505060405180910390fd5b6001546000838152600760205260409020546001600160401b03918216600160c01b90910482160181164290911610156111155760405162461bcd60e51b81526004018080602001828103825260358152602001806118eb6035913960400191505060405180910390fd5b6000828152600760205260408120556001600160a01b03831661114a5761114584826001600160c01b03166111cc565b61115e565b61115e8385836001600160c01b0316611261565b836001600160a01b0316836001600160a01b03167f72608e45b52a95a12c2ac7f15ff53f92fc9572c9d84b6e6b5d7f0f7826cf32718360405180826001600160c01b0316815260200191505060405180910390a3505060016000555050565b6003546001600160a01b031681565b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114611217576040519150601f19603f3d011682016040523d82523d6000602084013e61121c565b606091505b505090508061125c5760405162461bcd60e51b815260040180806020018281038252603281526020018061168d6032913960400191505060405180910390fd5b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b602083106112de5780518252601f1990920191602091820191016112bf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611340576040519150601f19603f3d011682016040523d82523d6000602084013e611345565b606091505b5091509150818015611373575080511580611373575080806020019051602081101561137057600080fd5b50515b6113ae5760405162461bcd60e51b815260040180806020018281038252603a815260200180611575603a913960400191505060405180910390fd5b5050505050565b60408051606085811b6001600160601b03199081166020808501919091529186901b166034830152825180830360280181526048909201835281519181019190912060008181526007909252919020546001600160c01b0390811683810191821610156114535760405162461bcd60e51b81526004018080602001828103825260348152602001806118716034913960400191505060405180910390fd5b60008281526007602090815260409182902080546001600160401b03428116600160c01b9081026001600160c01b038089166001600160c01b03199095169490941784161793849055855192891683529092049091169181019190915281516001600160a01b0380881693908916927f41219b99485f78192a5b9b1be28c7d53c3a2bdbe7900ae40c79fae8d9d6108fd929081900390910190a35050505050565b60408051808201909152600080825260208201529056fe5769746864726177616c44656c617965723a3a6465706f7369743a2057524f4e475f414d4f554e545769746864726177616c44656c617965723a3a636c61696d456d657267656e6379436f756e63696c3a204f4e4c595f50454e44494e475f474f5645524e414e43455769746864726177616c44656c617965723a3a5f746f6b656e5769746864726177616c3a20544f4b454e5f5452414e534645525f4641494c45445769746864726177616c44656c617965723a3a656e61626c65456d657267656e63794d6f64653a20414c52454144595f454e41424c45445769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204f4e4c595f454d4f44455769746864726177616c44656c617965723a3a6465706f7369743a2057524f4e475f544f4b454e5f414444524553535769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204e4f5f4d41585f454d455247454e43595f4d4f44455f54494d455769746864726177616c44656c617965723a3a5f6574685769746864726177616c3a205452414e534645525f4641494c45445769746864726177616c44656c617965723a3a636c61696d476f7665726e616e63653a204f4e4c595f50454e44494e475f474f5645524e414e43455769746864726177616c44656c617965723a3a7472616e73666572476f7665726e616e63653a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6368616e67655769746864726177616c44656c61793a204f4e4c595f524f4c4c55505f4f525f474f5645524e414e43455769746864726177616c44656c617965723a3a7472616e73666572456d657267656e6379436f756e63696c3a204f4e4c595f454d455247454e43595f434f554e43494c5769746864726177616c44656c617965723a3a6465706f7369743a204f4e4c595f524f4c4c55505769746864726177616c44656c617965723a3a6465706f7369743a20544f4b454e5f5452414e534645525f4641494c45445769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6465706f7369743a20454d455247454e43595f4d4f44455769746864726177616c44656c617965723a3a5f70726f636573734465706f7369743a204445504f5349545f4f564552464c4f575769746864726177616c44656c617965723a3a6368616e67655769746864726177616c44656c61793a20455843454544535f4d41585f5749544844524157414c5f44454c41595769746864726177616c44656c617965723a3a7769746864726177616c3a205749544844524157414c5f4e4f545f414c4c4f5745445769746864726177616c44656c617965723a3a656e61626c65456d657267656e63794d6f64653a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6465706f7369743a204e4f545f454e4f5547485f414c4c4f57414e43455769746864726177616c44656c617965723a3a7769746864726177616c3a204e4f5f46554e4453a2646970667358221220c4d2d2ed93c1882b6ac4ed396f96e7cb641d8d532478667c300863af7ce1fa4264736f6c634300060c00335769746864726177616c44656c617965723a3a7769746864726177616c44656c61796572496e697469616c697a657220414444524553535f305f4e4f545f56414c4944", + "deployedBytecode": "0x60806040526004361061012a5760003560e01c80637fd6b102116100ab578063ca79033f1161006f578063ca79033f1461036a578063cfc0b6411461037f578063d38bfff4146103bf578063db2a1a81146103f2578063de35f28214610425578063f39c38a0146104605761012a565b80637fd6b102146102d357806399ef11c514610316578063a238f9df1461032b578063b4b8e39d14610340578063c5b1c7d0146103555761012a565b80633d4dff7b116100f25780633d4dff7b14610204578063493b0170146102595780635d36b19014610294578063668cdd67146102a957806367fa2403146102be5761012a565b8063031609401461012f5780630b21d430146101605780630e670af5146101915780630fd266d7146101c657806320a194b8146101db575b600080fd5b34801561013b57600080fd5b50610144610475565b604080516001600160401b039092168252519081900360200190f35b34801561016c57600080fd5b50610175610484565b604080516001600160a01b039092168252519081900360200190f35b34801561019d57600080fd5b506101c4600480360360208110156101b457600080fd5b50356001600160401b0316610493565b005b3480156101d257600080fd5b50610175610597565b3480156101e757600080fd5b506101f06105a6565b604080519115158252519081900360200190f35b34801561021057600080fd5b5061022e6004803603602081101561022757600080fd5b50356105b6565b604080516001600160c01b0390931683526001600160401b0390911660208301528051918290030190f35b34801561026557600080fd5b5061022e6004803603604081101561027c57600080fd5b506001600160a01b03813581169160200135166105e3565b3480156102a057600080fd5b506101c4610674565b3480156102b557600080fd5b5061014461071e565b3480156102ca57600080fd5b50610175610734565b3480156102df57600080fd5b506101c4600480360360608110156102f657600080fd5b506001600160a01b03813581169160208101359091169060400135610743565b34801561032257600080fd5b5061017561095a565b34801561033757600080fd5b50610144610969565b34801561034c57600080fd5b50610144610970565b34801561036157600080fd5b506101c4610977565b34801561037657600080fd5b506101c4610a73565b6101c46004803603606081101561039557600080fd5b5080356001600160a01b0390811691602081013590911690604001356001600160c01b0316610b1d565b3480156103cb57600080fd5b506101c4600480360360208110156103e257600080fd5b50356001600160a01b0316610e99565b3480156103fe57600080fd5b506101c46004803603602081101561041557600080fd5b50356001600160a01b0316610f04565b34801561043157600080fd5b506101c46004803603604081101561044857600080fd5b506001600160a01b0381358116916020013516610f6f565b34801561046c57600080fd5b506101756111bd565b6001546001600160401b031690565b6002546001600160a01b031690565b6002546001600160a01b03163314806104b657506006546001600160a01b031633145b6104f15760405162461bcd60e51b81526004018080602001828103825260438152602001806117306043913960600191505060405180910390fd5b621275006001600160401b038216111561053c5760405162461bcd60e51b81526004018080602001828103825260468152602001806118a56046913960600191505060405180910390fd5b6001805467ffffffffffffffff19166001600160401b03838116919091179182905560408051929091168252517f6b3670ab51e04a9da086741e5fd1eb36ffaf1d661a15330c528e1f3e0c8722d7916020908290030190a150565b6006546001600160a01b031681565b600554600160a01b900460ff1690565b6007602052600090815260409020546001600160c01b03811690600160c01b90046001600160401b031682565b6000806105ee6114f4565b505060408051606094851b6001600160601b03199081166020808401919091529490951b90941660348501528051808503602801815260488501808352815191850191909120600090815260079094529281902060888501909152546001600160c01b03811692839052600160c01b90046001600160401b031660689093018390525091565b6003546001600160a01b031633146106bd5760405162461bcd60e51b815260040180806020018281038252603b8152602001806116bf603b913960400191505060405180910390fd5b60038054600280546001600160a01b038084166001600160a01b03199283161792839055921690925560408051929091168252517f3bf02437d5cd40067085d9dac2c3cdcbef0a449d98a259a40d9c24380aca81bf916020908290030190a1565b600154600160401b90046001600160401b031690565b6004546001600160a01b031681565b6002600054141561079b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055600554600160a01b900460ff166107e85760405162461bcd60e51b81526004018080602001828103825260348152602001806115e66034913960400191505060405180910390fd5b6005546001600160a01b031633148061080b57506002546001600160a01b031633145b6108465760405162461bcd60e51b815260040180806020018281038252603981526020018061180e6039913960400191505060405180910390fd5b6005546001600160a01b03163314801561087157506002546005546001600160a01b03908116911614155b156108d3576001546001600160401b03600160401b909104811662eff1000181164290911610156108d35760405162461bcd60e51b81526004018080602001828103825260448152602001806116496044913960600191505060405180910390fd5b6001600160a01b0382166108f0576108eb83826111cc565b6108fb565b6108fb828483611261565b816001600160a01b0316836001600160a01b0316336001600160a01b03167fde200220117ba95c9a6c4a1a13bb06b0b7be90faa85c8fb4576630119f891693846040518082815260200191505060405180910390a45050600160005550565b6005546001600160a01b031690565b6212750081565b62eff10081565b6002546001600160a01b031633146109c05760405162461bcd60e51b81526004018080602001828103825260378152602001806119206037913960400191505060405180910390fd5b600554600160a01b900460ff1615610a095760405162461bcd60e51b81526004018080602001828103825260378152602001806115af6037913960400191505060405180910390fd5b6005805460ff60a01b1916600160a01b179055600180546001600160401b034216600160401b026fffffffffffffffff0000000000000000199091161790556040517f2064d51aa5a8bd67928c7675e267e05c67ad5adf7c9098d0a602d01f36fda9c590600090a1565b6004546001600160a01b03163314610abc5760405162461bcd60e51b81526004018080602001828103825260418152602001806115346041913960600191505060405180910390fd5b60048054600580546001600160a01b038084166001600160a01b03199283161792839055921690925560408051929091168252517fcc267667d474ef34ee2de2d060e7c8b2c7295cefa22e57fd7049e22b5fdb5396916020908290030190a1565b60026000541415610b75576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000556006546001600160a01b03163314610bc35760405162461bcd60e51b81526004018080602001828103825260278152602001806117b66027913960400191505060405180910390fd5b3415610c5b576001600160a01b03821615610c0f5760405162461bcd60e51b815260040180806020018281038252602f81526020018061161a602f913960400191505060405180910390fd5b34816001600160c01b031614610c565760405162461bcd60e51b815260040180806020018281038252602881526020018061150c6028913960400191505060405180910390fd5b610e84565b60065460408051636eb1769f60e11b81526001600160a01b03928316600482015230602482015290516001600160c01b0384169285169163dd62ed3e916044808301926020929190829003018186803b158015610cb757600080fd5b505afa158015610ccb573d6000803e3d6000fd5b505050506040513d6020811015610ce157600080fd5b50511015610d205760405162461bcd60e51b81526004018080602001828103825260308152602001806119576030913960400191505060405180910390fd5b600654604080516001600160a01b0392831660248201523060448201526001600160c01b03841660648083019190915282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b178152915181516000946060949088169392918291908083835b60208310610db15780518252601f199092019160209182019101610d92565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610e13576040519150601f19603f3d011682016040523d82523d6000602084013e610e18565b606091505b5091509150818015610e46575080511580610e465750808060200190516020811015610e4357600080fd5b50515b610e815760405162461bcd60e51b81526004018080602001828103825260318152602001806117dd6031913960400191505060405180910390fd5b50505b610e8f8383836113b5565b5050600160005550565b6002546001600160a01b03163314610ee25760405162461bcd60e51b81526004018080602001828103825260368152602001806116fa6036913960400191505060405180910390fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6005546001600160a01b03163314610f4d5760405162461bcd60e51b81526004018080602001828103825260438152602001806117736043913960600191505060405180910390fd5b600480546001600160a01b0319166001600160a01b0392909216919091179055565b60026000541415610fc7576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055600554600160a01b900460ff16156110155760405162461bcd60e51b815260040180806020018281038252602a815260200180611847602a913960400191505060405180910390fd5b60408051606084811b6001600160601b03199081166020808501919091529185901b166034830152825180830360280181526048909201835281519181019190912060008181526007909252919020546001600160c01b0316806110aa5760405162461bcd60e51b81526004018080602001828103825260278152602001806119876027913960400191505060405180910390fd5b6001546000838152600760205260409020546001600160401b03918216600160c01b90910482160181164290911610156111155760405162461bcd60e51b81526004018080602001828103825260358152602001806118eb6035913960400191505060405180910390fd5b6000828152600760205260408120556001600160a01b03831661114a5761114584826001600160c01b03166111cc565b61115e565b61115e8385836001600160c01b0316611261565b836001600160a01b0316836001600160a01b03167f72608e45b52a95a12c2ac7f15ff53f92fc9572c9d84b6e6b5d7f0f7826cf32718360405180826001600160c01b0316815260200191505060405180910390a3505060016000555050565b6003546001600160a01b031681565b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114611217576040519150601f19603f3d011682016040523d82523d6000602084013e61121c565b606091505b505090508061125c5760405162461bcd60e51b815260040180806020018281038252603281526020018061168d6032913960400191505060405180910390fd5b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b178152925182516000946060949389169392918291908083835b602083106112de5780518252601f1990920191602091820191016112bf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114611340576040519150601f19603f3d011682016040523d82523d6000602084013e611345565b606091505b5091509150818015611373575080511580611373575080806020019051602081101561137057600080fd5b50515b6113ae5760405162461bcd60e51b815260040180806020018281038252603a815260200180611575603a913960400191505060405180910390fd5b5050505050565b60408051606085811b6001600160601b03199081166020808501919091529186901b166034830152825180830360280181526048909201835281519181019190912060008181526007909252919020546001600160c01b0390811683810191821610156114535760405162461bcd60e51b81526004018080602001828103825260348152602001806118716034913960400191505060405180910390fd5b60008281526007602090815260409182902080546001600160401b03428116600160c01b9081026001600160c01b038089166001600160c01b03199095169490941784161793849055855192891683529092049091169181019190915281516001600160a01b0380881693908916927f41219b99485f78192a5b9b1be28c7d53c3a2bdbe7900ae40c79fae8d9d6108fd929081900390910190a35050505050565b60408051808201909152600080825260208201529056fe5769746864726177616c44656c617965723a3a6465706f7369743a2057524f4e475f414d4f554e545769746864726177616c44656c617965723a3a636c61696d456d657267656e6379436f756e63696c3a204f4e4c595f50454e44494e475f474f5645524e414e43455769746864726177616c44656c617965723a3a5f746f6b656e5769746864726177616c3a20544f4b454e5f5452414e534645525f4641494c45445769746864726177616c44656c617965723a3a656e61626c65456d657267656e63794d6f64653a20414c52454144595f454e41424c45445769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204f4e4c595f454d4f44455769746864726177616c44656c617965723a3a6465706f7369743a2057524f4e475f544f4b454e5f414444524553535769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204e4f5f4d41585f454d455247454e43595f4d4f44455f54494d455769746864726177616c44656c617965723a3a5f6574685769746864726177616c3a205452414e534645525f4641494c45445769746864726177616c44656c617965723a3a636c61696d476f7665726e616e63653a204f4e4c595f50454e44494e475f474f5645524e414e43455769746864726177616c44656c617965723a3a7472616e73666572476f7665726e616e63653a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6368616e67655769746864726177616c44656c61793a204f4e4c595f524f4c4c55505f4f525f474f5645524e414e43455769746864726177616c44656c617965723a3a7472616e73666572456d657267656e6379436f756e63696c3a204f4e4c595f454d455247454e43595f434f554e43494c5769746864726177616c44656c617965723a3a6465706f7369743a204f4e4c595f524f4c4c55505769746864726177616c44656c617965723a3a6465706f7369743a20544f4b454e5f5452414e534645525f4641494c45445769746864726177616c44656c617965723a3a65736361706548617463685769746864726177616c3a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6465706f7369743a20454d455247454e43595f4d4f44455769746864726177616c44656c617965723a3a5f70726f636573734465706f7369743a204445504f5349545f4f564552464c4f575769746864726177616c44656c617965723a3a6368616e67655769746864726177616c44656c61793a20455843454544535f4d41585f5749544844524157414c5f44454c41595769746864726177616c44656c617965723a3a7769746864726177616c3a205749544844524157414c5f4e4f545f414c4c4f5745445769746864726177616c44656c617965723a3a656e61626c65456d657267656e63794d6f64653a204f4e4c595f474f5645524e414e43455769746864726177616c44656c617965723a3a6465706f7369743a204e4f545f454e4f5547485f414c4c4f57414e43455769746864726177616c44656c617965723a3a7769746864726177616c3a204e4f5f46554e4453a2646970667358221220c4d2d2ed93c1882b6ac4ed396f96e7cb641d8d532478667c300863af7ce1fa4264736f6c634300060c0033", + "linkReferences": {}, + "deployedLinkReferences": {} +} diff --git a/eth/contracts/auction/HermezAuctionProtocol.go b/eth/contracts/auction/auction.go similarity index 50% rename from eth/contracts/auction/HermezAuctionProtocol.go rename to eth/contracts/auction/auction.go index 43e4d7120..47cc9ed84 100644 --- a/eth/contracts/auction/HermezAuctionProtocol.go +++ b/eth/contracts/auction/auction.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package HermezAuctionProtocol +package auction import ( "math/big" @@ -26,107 +26,107 @@ var ( _ = event.NewSubscription ) -// HermezAuctionProtocolABI is the input ABI used to generate the binding from. -const HermezAuctionProtocolABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"HEZClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"donationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bootCoordinatorAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"bootCoordinatorURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"outbidding\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"slotDeadline\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"closedAuctionSlots\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"openAuctionSlots\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16[3]\",\"name\":\"allocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"InitializeHermezAuctionProtocolEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16[3]\",\"name\":\"newAllocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"NewAllocationRatio\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"}],\"name\":\"NewBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newBootCoordinator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"newBootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"NewBootCoordinator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newClosedAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"NewClosedAuctionSlots\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"slotSet\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"newInitialMinBid\",\"type\":\"uint128\"}],\"name\":\"NewDefaultSlotSetBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newDonationAddress\",\"type\":\"address\"}],\"name\":\"NewDonationAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slotToForge\",\"type\":\"uint128\"}],\"name\":\"NewForge\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slotToForge\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"burnAmount\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"donationAmount\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"governanceAmount\",\"type\":\"uint128\"}],\"name\":\"NewForgeAllocated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newOpenAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"NewOpenAuctionSlots\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newOutbidding\",\"type\":\"uint16\"}],\"name\":\"NewOutbidding\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"newSlotDeadline\",\"type\":\"uint8\"}],\"name\":\"NewSlotDeadline\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"name\":\"SetCoordinator\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BLOCKS_PER_SLOT\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"INITIAL_MINIMAL_BIDDING\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bootCoordinatorURL\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"canForge\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slotSet\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"newInitialMinBid\",\"type\":\"uint128\"}],\"name\":\"changeDefaultSlotSetBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimHEZ\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"claimPendingHEZ\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"coordinators\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"}],\"name\":\"forge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisBlock\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllocationRatio\",\"outputs\":[{\"internalType\":\"uint16[3]\",\"name\":\"\",\"type\":\"uint16[3]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBootCoordinator\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"}],\"name\":\"getClaimableHEZ\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getClosedAuctionSlots\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentSlotNumber\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"slotSet\",\"type\":\"uint8\"}],\"name\":\"getDefaultSlotSetBid\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDonationAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"getMinBidBySlot\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOpenAuctionSlots\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOutbidding\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSlotDeadline\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"blockNumber\",\"type\":\"uint128\"}],\"name\":\"getSlotNumber\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"getSlotSet\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governanceAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint128\",\"name\":\"genesis\",\"type\":\"uint128\"},{\"internalType\":\"address\",\"name\":\"hermezRollupAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_governanceAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"donationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bootCoordinatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_bootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"hermezAuctionProtocolInitializer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hermezRollup\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingBalances\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"}],\"name\":\"processBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"startingSlot\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"endingSlot\",\"type\":\"uint128\"},{\"internalType\":\"bool[6]\",\"name\":\"slotSets\",\"type\":\"bool[6]\"},{\"internalType\":\"uint128\",\"name\":\"maxBid\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"minBid\",\"type\":\"uint128\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"}],\"name\":\"processMultiBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16[3]\",\"name\":\"newAllocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"setAllocationRatio\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newBootCoordinator\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"newBootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"setBootCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newClosedAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"setClosedAuctionSlots\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"name\":\"setCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newDonationAddress\",\"type\":\"address\"}],\"name\":\"setDonationAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newOpenAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"setOpenAuctionSlots\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newOutbidding\",\"type\":\"uint16\"}],\"name\":\"setOutbidding\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"newDeadline\",\"type\":\"uint8\"}],\"name\":\"setSlotDeadline\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"name\":\"slots\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"forgerCommitment\",\"type\":\"bool\"},{\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"closedMinBid\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenHEZ\",\"outputs\":[{\"internalType\":\"contractIHEZToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" +// AuctionABI is the input ABI used to generate the binding from. +const AuctionABI = "[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"}],\"name\":\"HEZClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"donationAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"bootCoordinatorAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"bootCoordinatorURL\",\"type\":\"string\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"outbidding\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"slotDeadline\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"closedAuctionSlots\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"openAuctionSlots\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint16[3]\",\"name\":\"allocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"InitializeHermezAuctionProtocolEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16[3]\",\"name\":\"newAllocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"NewAllocationRatio\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"}],\"name\":\"NewBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newBootCoordinator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"newBootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"NewBootCoordinator\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newClosedAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"NewClosedAuctionSlots\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"slotSet\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"newInitialMinBid\",\"type\":\"uint128\"}],\"name\":\"NewDefaultSlotSetBid\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newDonationAddress\",\"type\":\"address\"}],\"name\":\"NewDonationAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slotToForge\",\"type\":\"uint128\"}],\"name\":\"NewForge\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint128\",\"name\":\"slotToForge\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"burnAmount\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"donationAmount\",\"type\":\"uint128\"},{\"indexed\":false,\"internalType\":\"uint128\",\"name\":\"governanceAmount\",\"type\":\"uint128\"}],\"name\":\"NewForgeAllocated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newOpenAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"NewOpenAuctionSlots\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"newOutbidding\",\"type\":\"uint16\"}],\"name\":\"NewOutbidding\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"newSlotDeadline\",\"type\":\"uint8\"}],\"name\":\"NewSlotDeadline\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"name\":\"SetCoordinator\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"BLOCKS_PER_SLOT\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"INITIAL_MINIMAL_BIDDING\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bootCoordinatorURL\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"canForge\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slotSet\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"newInitialMinBid\",\"type\":\"uint128\"}],\"name\":\"changeDefaultSlotSetBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimHEZ\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"claimPendingHEZ\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"coordinators\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"}],\"name\":\"forge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"genesisBlock\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAllocationRatio\",\"outputs\":[{\"internalType\":\"uint16[3]\",\"name\":\"\",\"type\":\"uint16[3]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getBootCoordinator\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"}],\"name\":\"getClaimableHEZ\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getClosedAuctionSlots\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCurrentSlotNumber\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"slotSet\",\"type\":\"uint8\"}],\"name\":\"getDefaultSlotSetBid\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDonationAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"getMinBidBySlot\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOpenAuctionSlots\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getOutbidding\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSlotDeadline\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"blockNumber\",\"type\":\"uint128\"}],\"name\":\"getSlotNumber\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"}],\"name\":\"getSlotSet\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governanceAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint128\",\"name\":\"genesis\",\"type\":\"uint128\"},{\"internalType\":\"address\",\"name\":\"hermezRollupAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_governanceAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"donationAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"bootCoordinatorAddress\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"_bootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"hermezAuctionProtocolInitializer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hermezRollup\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"pendingBalances\",\"outputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"slot\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"}],\"name\":\"processBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"amount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"startingSlot\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"endingSlot\",\"type\":\"uint128\"},{\"internalType\":\"bool[6]\",\"name\":\"slotSets\",\"type\":\"bool[6]\"},{\"internalType\":\"uint128\",\"name\":\"maxBid\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"minBid\",\"type\":\"uint128\"},{\"internalType\":\"bytes\",\"name\":\"permit\",\"type\":\"bytes\"}],\"name\":\"processMultiBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16[3]\",\"name\":\"newAllocationRatio\",\"type\":\"uint16[3]\"}],\"name\":\"setAllocationRatio\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newBootCoordinator\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"newBootCoordinatorURL\",\"type\":\"string\"}],\"name\":\"setBootCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newClosedAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"setClosedAuctionSlots\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forger\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"coordinatorURL\",\"type\":\"string\"}],\"name\":\"setCoordinator\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newDonationAddress\",\"type\":\"address\"}],\"name\":\"setDonationAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newOpenAuctionSlots\",\"type\":\"uint16\"}],\"name\":\"setOpenAuctionSlots\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint16\",\"name\":\"newOutbidding\",\"type\":\"uint16\"}],\"name\":\"setOutbidding\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"newDeadline\",\"type\":\"uint8\"}],\"name\":\"setSlotDeadline\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint128\",\"name\":\"\",\"type\":\"uint128\"}],\"name\":\"slots\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"bidder\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"fulfilled\",\"type\":\"bool\"},{\"internalType\":\"bool\",\"name\":\"forgerCommitment\",\"type\":\"bool\"},{\"internalType\":\"uint128\",\"name\":\"bidAmount\",\"type\":\"uint128\"},{\"internalType\":\"uint128\",\"name\":\"closedMinBid\",\"type\":\"uint128\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenHEZ\",\"outputs\":[{\"internalType\":\"contractIHEZToken\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]" -// HermezAuctionProtocol is an auto generated Go binding around an Ethereum contract. -type HermezAuctionProtocol struct { - HermezAuctionProtocolCaller // Read-only binding to the contract - HermezAuctionProtocolTransactor // Write-only binding to the contract - HermezAuctionProtocolFilterer // Log filterer for contract events +// Auction is an auto generated Go binding around an Ethereum contract. +type Auction struct { + AuctionCaller // Read-only binding to the contract + AuctionTransactor // Write-only binding to the contract + AuctionFilterer // Log filterer for contract events } -// HermezAuctionProtocolCaller is an auto generated read-only Go binding around an Ethereum contract. -type HermezAuctionProtocolCaller struct { +// AuctionCaller is an auto generated read-only Go binding around an Ethereum contract. +type AuctionCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HermezAuctionProtocolTransactor is an auto generated write-only Go binding around an Ethereum contract. -type HermezAuctionProtocolTransactor struct { +// AuctionTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AuctionTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HermezAuctionProtocolFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type HermezAuctionProtocolFilterer struct { +// AuctionFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AuctionFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HermezAuctionProtocolSession is an auto generated Go binding around an Ethereum contract, +// AuctionSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. -type HermezAuctionProtocolSession struct { - Contract *HermezAuctionProtocol // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +type AuctionSession struct { + Contract *Auction // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// HermezAuctionProtocolCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// AuctionCallerSession is an auto generated read-only Go binding around an Ethereum contract, // with pre-set call options. -type HermezAuctionProtocolCallerSession struct { - Contract *HermezAuctionProtocolCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session +type AuctionCallerSession struct { + Contract *AuctionCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session } -// HermezAuctionProtocolTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// AuctionTransactorSession is an auto generated write-only Go binding around an Ethereum contract, // with pre-set transact options. -type HermezAuctionProtocolTransactorSession struct { - Contract *HermezAuctionProtocolTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +type AuctionTransactorSession struct { + Contract *AuctionTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// HermezAuctionProtocolRaw is an auto generated low-level Go binding around an Ethereum contract. -type HermezAuctionProtocolRaw struct { - Contract *HermezAuctionProtocol // Generic contract binding to access the raw methods on +// AuctionRaw is an auto generated low-level Go binding around an Ethereum contract. +type AuctionRaw struct { + Contract *Auction // Generic contract binding to access the raw methods on } -// HermezAuctionProtocolCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type HermezAuctionProtocolCallerRaw struct { - Contract *HermezAuctionProtocolCaller // Generic read-only contract binding to access the raw methods on +// AuctionCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AuctionCallerRaw struct { + Contract *AuctionCaller // Generic read-only contract binding to access the raw methods on } -// HermezAuctionProtocolTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type HermezAuctionProtocolTransactorRaw struct { - Contract *HermezAuctionProtocolTransactor // Generic write-only contract binding to access the raw methods on +// AuctionTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AuctionTransactorRaw struct { + Contract *AuctionTransactor // Generic write-only contract binding to access the raw methods on } -// NewHermezAuctionProtocol creates a new instance of HermezAuctionProtocol, bound to a specific deployed contract. -func NewHermezAuctionProtocol(address common.Address, backend bind.ContractBackend) (*HermezAuctionProtocol, error) { - contract, err := bindHermezAuctionProtocol(address, backend, backend, backend) +// NewAuction creates a new instance of Auction, bound to a specific deployed contract. +func NewAuction(address common.Address, backend bind.ContractBackend) (*Auction, error) { + contract, err := bindAuction(address, backend, backend, backend) if err != nil { return nil, err } - return &HermezAuctionProtocol{HermezAuctionProtocolCaller: HermezAuctionProtocolCaller{contract: contract}, HermezAuctionProtocolTransactor: HermezAuctionProtocolTransactor{contract: contract}, HermezAuctionProtocolFilterer: HermezAuctionProtocolFilterer{contract: contract}}, nil + return &Auction{AuctionCaller: AuctionCaller{contract: contract}, AuctionTransactor: AuctionTransactor{contract: contract}, AuctionFilterer: AuctionFilterer{contract: contract}}, nil } -// NewHermezAuctionProtocolCaller creates a new read-only instance of HermezAuctionProtocol, bound to a specific deployed contract. -func NewHermezAuctionProtocolCaller(address common.Address, caller bind.ContractCaller) (*HermezAuctionProtocolCaller, error) { - contract, err := bindHermezAuctionProtocol(address, caller, nil, nil) +// NewAuctionCaller creates a new read-only instance of Auction, bound to a specific deployed contract. +func NewAuctionCaller(address common.Address, caller bind.ContractCaller) (*AuctionCaller, error) { + contract, err := bindAuction(address, caller, nil, nil) if err != nil { return nil, err } - return &HermezAuctionProtocolCaller{contract: contract}, nil + return &AuctionCaller{contract: contract}, nil } -// NewHermezAuctionProtocolTransactor creates a new write-only instance of HermezAuctionProtocol, bound to a specific deployed contract. -func NewHermezAuctionProtocolTransactor(address common.Address, transactor bind.ContractTransactor) (*HermezAuctionProtocolTransactor, error) { - contract, err := bindHermezAuctionProtocol(address, nil, transactor, nil) +// NewAuctionTransactor creates a new write-only instance of Auction, bound to a specific deployed contract. +func NewAuctionTransactor(address common.Address, transactor bind.ContractTransactor) (*AuctionTransactor, error) { + contract, err := bindAuction(address, nil, transactor, nil) if err != nil { return nil, err } - return &HermezAuctionProtocolTransactor{contract: contract}, nil + return &AuctionTransactor{contract: contract}, nil } -// NewHermezAuctionProtocolFilterer creates a new log filterer instance of HermezAuctionProtocol, bound to a specific deployed contract. -func NewHermezAuctionProtocolFilterer(address common.Address, filterer bind.ContractFilterer) (*HermezAuctionProtocolFilterer, error) { - contract, err := bindHermezAuctionProtocol(address, nil, nil, filterer) +// NewAuctionFilterer creates a new log filterer instance of Auction, bound to a specific deployed contract. +func NewAuctionFilterer(address common.Address, filterer bind.ContractFilterer) (*AuctionFilterer, error) { + contract, err := bindAuction(address, nil, nil, filterer) if err != nil { return nil, err } - return &HermezAuctionProtocolFilterer{contract: contract}, nil + return &AuctionFilterer{contract: contract}, nil } -// bindHermezAuctionProtocol binds a generic wrapper to an already deployed contract. -func bindHermezAuctionProtocol(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(HermezAuctionProtocolABI)) +// bindAuction binds a generic wrapper to an already deployed contract. +func bindAuction(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(AuctionABI)) if err != nil { return nil, err } @@ -137,46 +137,46 @@ func bindHermezAuctionProtocol(address common.Address, caller bind.ContractCalle // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_HermezAuctionProtocol *HermezAuctionProtocolRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HermezAuctionProtocol.Contract.HermezAuctionProtocolCaller.contract.Call(opts, result, method, params...) +func (_Auction *AuctionRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Auction.Contract.AuctionCaller.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_HermezAuctionProtocol *HermezAuctionProtocolRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.HermezAuctionProtocolTransactor.contract.Transfer(opts) +func (_Auction *AuctionRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Auction.Contract.AuctionTransactor.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_HermezAuctionProtocol *HermezAuctionProtocolRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.HermezAuctionProtocolTransactor.contract.Transact(opts, method, params...) +func (_Auction *AuctionRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Auction.Contract.AuctionTransactor.contract.Transact(opts, method, params...) } // Call invokes the (constant) contract method with params as input values and // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HermezAuctionProtocol.Contract.contract.Call(opts, result, method, params...) +func (_Auction *AuctionCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Auction.Contract.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.contract.Transfer(opts) +func (_Auction *AuctionTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Auction.Contract.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.contract.Transact(opts, method, params...) +func (_Auction *AuctionTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Auction.Contract.contract.Transact(opts, method, params...) } // BLOCKSPERSLOT is a free data retrieval call binding the contract method 0x2243de47. // // Solidity: function BLOCKS_PER_SLOT() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) BLOCKSPERSLOT(opts *bind.CallOpts) (uint8, error) { +func (_Auction *AuctionCaller) BLOCKSPERSLOT(opts *bind.CallOpts) (uint8, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "BLOCKS_PER_SLOT") + err := _Auction.contract.Call(opts, &out, "BLOCKS_PER_SLOT") if err != nil { return *new(uint8), err @@ -191,23 +191,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) BLOCKSPERSLOT(opts *b // BLOCKSPERSLOT is a free data retrieval call binding the contract method 0x2243de47. // // Solidity: function BLOCKS_PER_SLOT() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) BLOCKSPERSLOT() (uint8, error) { - return _HermezAuctionProtocol.Contract.BLOCKSPERSLOT(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) BLOCKSPERSLOT() (uint8, error) { + return _Auction.Contract.BLOCKSPERSLOT(&_Auction.CallOpts) } // BLOCKSPERSLOT is a free data retrieval call binding the contract method 0x2243de47. // // Solidity: function BLOCKS_PER_SLOT() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) BLOCKSPERSLOT() (uint8, error) { - return _HermezAuctionProtocol.Contract.BLOCKSPERSLOT(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) BLOCKSPERSLOT() (uint8, error) { + return _Auction.Contract.BLOCKSPERSLOT(&_Auction.CallOpts) } // INITIALMINIMALBIDDING is a free data retrieval call binding the contract method 0xe6065914. // // Solidity: function INITIAL_MINIMAL_BIDDING() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) INITIALMINIMALBIDDING(opts *bind.CallOpts) (*big.Int, error) { +func (_Auction *AuctionCaller) INITIALMINIMALBIDDING(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "INITIAL_MINIMAL_BIDDING") + err := _Auction.contract.Call(opts, &out, "INITIAL_MINIMAL_BIDDING") if err != nil { return *new(*big.Int), err @@ -222,23 +222,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) INITIALMINIMALBIDDING // INITIALMINIMALBIDDING is a free data retrieval call binding the contract method 0xe6065914. // // Solidity: function INITIAL_MINIMAL_BIDDING() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) INITIALMINIMALBIDDING() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.INITIALMINIMALBIDDING(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) INITIALMINIMALBIDDING() (*big.Int, error) { + return _Auction.Contract.INITIALMINIMALBIDDING(&_Auction.CallOpts) } // INITIALMINIMALBIDDING is a free data retrieval call binding the contract method 0xe6065914. // // Solidity: function INITIAL_MINIMAL_BIDDING() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) INITIALMINIMALBIDDING() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.INITIALMINIMALBIDDING(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) INITIALMINIMALBIDDING() (*big.Int, error) { + return _Auction.Contract.INITIALMINIMALBIDDING(&_Auction.CallOpts) } // BootCoordinatorURL is a free data retrieval call binding the contract method 0x72ca58a3. // // Solidity: function bootCoordinatorURL() view returns(string) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) BootCoordinatorURL(opts *bind.CallOpts) (string, error) { +func (_Auction *AuctionCaller) BootCoordinatorURL(opts *bind.CallOpts) (string, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "bootCoordinatorURL") + err := _Auction.contract.Call(opts, &out, "bootCoordinatorURL") if err != nil { return *new(string), err @@ -253,23 +253,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) BootCoordinatorURL(op // BootCoordinatorURL is a free data retrieval call binding the contract method 0x72ca58a3. // // Solidity: function bootCoordinatorURL() view returns(string) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) BootCoordinatorURL() (string, error) { - return _HermezAuctionProtocol.Contract.BootCoordinatorURL(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) BootCoordinatorURL() (string, error) { + return _Auction.Contract.BootCoordinatorURL(&_Auction.CallOpts) } // BootCoordinatorURL is a free data retrieval call binding the contract method 0x72ca58a3. // // Solidity: function bootCoordinatorURL() view returns(string) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) BootCoordinatorURL() (string, error) { - return _HermezAuctionProtocol.Contract.BootCoordinatorURL(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) BootCoordinatorURL() (string, error) { + return _Auction.Contract.BootCoordinatorURL(&_Auction.CallOpts) } // CanForge is a free data retrieval call binding the contract method 0x83b1f6a0. // // Solidity: function canForge(address forger, uint256 blockNumber) view returns(bool) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) CanForge(opts *bind.CallOpts, forger common.Address, blockNumber *big.Int) (bool, error) { +func (_Auction *AuctionCaller) CanForge(opts *bind.CallOpts, forger common.Address, blockNumber *big.Int) (bool, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "canForge", forger, blockNumber) + err := _Auction.contract.Call(opts, &out, "canForge", forger, blockNumber) if err != nil { return *new(bool), err @@ -284,26 +284,26 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) CanForge(opts *bind.C // CanForge is a free data retrieval call binding the contract method 0x83b1f6a0. // // Solidity: function canForge(address forger, uint256 blockNumber) view returns(bool) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) CanForge(forger common.Address, blockNumber *big.Int) (bool, error) { - return _HermezAuctionProtocol.Contract.CanForge(&_HermezAuctionProtocol.CallOpts, forger, blockNumber) +func (_Auction *AuctionSession) CanForge(forger common.Address, blockNumber *big.Int) (bool, error) { + return _Auction.Contract.CanForge(&_Auction.CallOpts, forger, blockNumber) } // CanForge is a free data retrieval call binding the contract method 0x83b1f6a0. // // Solidity: function canForge(address forger, uint256 blockNumber) view returns(bool) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) CanForge(forger common.Address, blockNumber *big.Int) (bool, error) { - return _HermezAuctionProtocol.Contract.CanForge(&_HermezAuctionProtocol.CallOpts, forger, blockNumber) +func (_Auction *AuctionCallerSession) CanForge(forger common.Address, blockNumber *big.Int) (bool, error) { + return _Auction.Contract.CanForge(&_Auction.CallOpts, forger, blockNumber) } // Coordinators is a free data retrieval call binding the contract method 0xa48af096. // // Solidity: function coordinators(address ) view returns(address forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Coordinators(opts *bind.CallOpts, arg0 common.Address) (struct { +func (_Auction *AuctionCaller) Coordinators(opts *bind.CallOpts, arg0 common.Address) (struct { Forger common.Address CoordinatorURL string }, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "coordinators", arg0) + err := _Auction.contract.Call(opts, &out, "coordinators", arg0) outstruct := new(struct { Forger common.Address @@ -323,29 +323,29 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Coordinators(opts *bi // Coordinators is a free data retrieval call binding the contract method 0xa48af096. // // Solidity: function coordinators(address ) view returns(address forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) Coordinators(arg0 common.Address) (struct { +func (_Auction *AuctionSession) Coordinators(arg0 common.Address) (struct { Forger common.Address CoordinatorURL string }, error) { - return _HermezAuctionProtocol.Contract.Coordinators(&_HermezAuctionProtocol.CallOpts, arg0) + return _Auction.Contract.Coordinators(&_Auction.CallOpts, arg0) } // Coordinators is a free data retrieval call binding the contract method 0xa48af096. // // Solidity: function coordinators(address ) view returns(address forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) Coordinators(arg0 common.Address) (struct { +func (_Auction *AuctionCallerSession) Coordinators(arg0 common.Address) (struct { Forger common.Address CoordinatorURL string }, error) { - return _HermezAuctionProtocol.Contract.Coordinators(&_HermezAuctionProtocol.CallOpts, arg0) + return _Auction.Contract.Coordinators(&_Auction.CallOpts, arg0) } // GenesisBlock is a free data retrieval call binding the contract method 0x4cdc9c63. // // Solidity: function genesisBlock() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GenesisBlock(opts *bind.CallOpts) (*big.Int, error) { +func (_Auction *AuctionCaller) GenesisBlock(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "genesisBlock") + err := _Auction.contract.Call(opts, &out, "genesisBlock") if err != nil { return *new(*big.Int), err @@ -360,23 +360,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GenesisBlock(opts *bi // GenesisBlock is a free data retrieval call binding the contract method 0x4cdc9c63. // // Solidity: function genesisBlock() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GenesisBlock() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GenesisBlock(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GenesisBlock() (*big.Int, error) { + return _Auction.Contract.GenesisBlock(&_Auction.CallOpts) } // GenesisBlock is a free data retrieval call binding the contract method 0x4cdc9c63. // // Solidity: function genesisBlock() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GenesisBlock() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GenesisBlock(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GenesisBlock() (*big.Int, error) { + return _Auction.Contract.GenesisBlock(&_Auction.CallOpts) } // GetAllocationRatio is a free data retrieval call binding the contract method 0xec29159b. // // Solidity: function getAllocationRatio() view returns(uint16[3]) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetAllocationRatio(opts *bind.CallOpts) ([3]uint16, error) { +func (_Auction *AuctionCaller) GetAllocationRatio(opts *bind.CallOpts) ([3]uint16, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getAllocationRatio") + err := _Auction.contract.Call(opts, &out, "getAllocationRatio") if err != nil { return *new([3]uint16), err @@ -391,23 +391,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetAllocationRatio(op // GetAllocationRatio is a free data retrieval call binding the contract method 0xec29159b. // // Solidity: function getAllocationRatio() view returns(uint16[3]) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetAllocationRatio() ([3]uint16, error) { - return _HermezAuctionProtocol.Contract.GetAllocationRatio(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetAllocationRatio() ([3]uint16, error) { + return _Auction.Contract.GetAllocationRatio(&_Auction.CallOpts) } // GetAllocationRatio is a free data retrieval call binding the contract method 0xec29159b. // // Solidity: function getAllocationRatio() view returns(uint16[3]) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetAllocationRatio() ([3]uint16, error) { - return _HermezAuctionProtocol.Contract.GetAllocationRatio(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetAllocationRatio() ([3]uint16, error) { + return _Auction.Contract.GetAllocationRatio(&_Auction.CallOpts) } // GetBootCoordinator is a free data retrieval call binding the contract method 0xb5f7f2f0. // // Solidity: function getBootCoordinator() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetBootCoordinator(opts *bind.CallOpts) (common.Address, error) { +func (_Auction *AuctionCaller) GetBootCoordinator(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getBootCoordinator") + err := _Auction.contract.Call(opts, &out, "getBootCoordinator") if err != nil { return *new(common.Address), err @@ -422,23 +422,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetBootCoordinator(op // GetBootCoordinator is a free data retrieval call binding the contract method 0xb5f7f2f0. // // Solidity: function getBootCoordinator() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetBootCoordinator() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GetBootCoordinator(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetBootCoordinator() (common.Address, error) { + return _Auction.Contract.GetBootCoordinator(&_Auction.CallOpts) } // GetBootCoordinator is a free data retrieval call binding the contract method 0xb5f7f2f0. // // Solidity: function getBootCoordinator() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetBootCoordinator() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GetBootCoordinator(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetBootCoordinator() (common.Address, error) { + return _Auction.Contract.GetBootCoordinator(&_Auction.CallOpts) } // GetClaimableHEZ is a free data retrieval call binding the contract method 0x5cca4903. // // Solidity: function getClaimableHEZ(address bidder) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetClaimableHEZ(opts *bind.CallOpts, bidder common.Address) (*big.Int, error) { +func (_Auction *AuctionCaller) GetClaimableHEZ(opts *bind.CallOpts, bidder common.Address) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getClaimableHEZ", bidder) + err := _Auction.contract.Call(opts, &out, "getClaimableHEZ", bidder) if err != nil { return *new(*big.Int), err @@ -453,23 +453,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetClaimableHEZ(opts // GetClaimableHEZ is a free data retrieval call binding the contract method 0x5cca4903. // // Solidity: function getClaimableHEZ(address bidder) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetClaimableHEZ(bidder common.Address) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetClaimableHEZ(&_HermezAuctionProtocol.CallOpts, bidder) +func (_Auction *AuctionSession) GetClaimableHEZ(bidder common.Address) (*big.Int, error) { + return _Auction.Contract.GetClaimableHEZ(&_Auction.CallOpts, bidder) } // GetClaimableHEZ is a free data retrieval call binding the contract method 0x5cca4903. // // Solidity: function getClaimableHEZ(address bidder) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetClaimableHEZ(bidder common.Address) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetClaimableHEZ(&_HermezAuctionProtocol.CallOpts, bidder) +func (_Auction *AuctionCallerSession) GetClaimableHEZ(bidder common.Address) (*big.Int, error) { + return _Auction.Contract.GetClaimableHEZ(&_Auction.CallOpts, bidder) } // GetClosedAuctionSlots is a free data retrieval call binding the contract method 0x4da9639d. // // Solidity: function getClosedAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetClosedAuctionSlots(opts *bind.CallOpts) (uint16, error) { +func (_Auction *AuctionCaller) GetClosedAuctionSlots(opts *bind.CallOpts) (uint16, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getClosedAuctionSlots") + err := _Auction.contract.Call(opts, &out, "getClosedAuctionSlots") if err != nil { return *new(uint16), err @@ -484,23 +484,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetClosedAuctionSlots // GetClosedAuctionSlots is a free data retrieval call binding the contract method 0x4da9639d. // // Solidity: function getClosedAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetClosedAuctionSlots() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetClosedAuctionSlots(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetClosedAuctionSlots() (uint16, error) { + return _Auction.Contract.GetClosedAuctionSlots(&_Auction.CallOpts) } // GetClosedAuctionSlots is a free data retrieval call binding the contract method 0x4da9639d. // // Solidity: function getClosedAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetClosedAuctionSlots() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetClosedAuctionSlots(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetClosedAuctionSlots() (uint16, error) { + return _Auction.Contract.GetClosedAuctionSlots(&_Auction.CallOpts) } // GetCurrentSlotNumber is a free data retrieval call binding the contract method 0x0c4da4f6. // // Solidity: function getCurrentSlotNumber() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetCurrentSlotNumber(opts *bind.CallOpts) (*big.Int, error) { +func (_Auction *AuctionCaller) GetCurrentSlotNumber(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getCurrentSlotNumber") + err := _Auction.contract.Call(opts, &out, "getCurrentSlotNumber") if err != nil { return *new(*big.Int), err @@ -515,23 +515,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetCurrentSlotNumber( // GetCurrentSlotNumber is a free data retrieval call binding the contract method 0x0c4da4f6. // // Solidity: function getCurrentSlotNumber() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetCurrentSlotNumber() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetCurrentSlotNumber(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetCurrentSlotNumber() (*big.Int, error) { + return _Auction.Contract.GetCurrentSlotNumber(&_Auction.CallOpts) } // GetCurrentSlotNumber is a free data retrieval call binding the contract method 0x0c4da4f6. // // Solidity: function getCurrentSlotNumber() view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetCurrentSlotNumber() (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetCurrentSlotNumber(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetCurrentSlotNumber() (*big.Int, error) { + return _Auction.Contract.GetCurrentSlotNumber(&_Auction.CallOpts) } // GetDefaultSlotSetBid is a free data retrieval call binding the contract method 0x564e6a71. // // Solidity: function getDefaultSlotSetBid(uint8 slotSet) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetDefaultSlotSetBid(opts *bind.CallOpts, slotSet uint8) (*big.Int, error) { +func (_Auction *AuctionCaller) GetDefaultSlotSetBid(opts *bind.CallOpts, slotSet uint8) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getDefaultSlotSetBid", slotSet) + err := _Auction.contract.Call(opts, &out, "getDefaultSlotSetBid", slotSet) if err != nil { return *new(*big.Int), err @@ -546,23 +546,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetDefaultSlotSetBid( // GetDefaultSlotSetBid is a free data retrieval call binding the contract method 0x564e6a71. // // Solidity: function getDefaultSlotSetBid(uint8 slotSet) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetDefaultSlotSetBid(&_HermezAuctionProtocol.CallOpts, slotSet) +func (_Auction *AuctionSession) GetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { + return _Auction.Contract.GetDefaultSlotSetBid(&_Auction.CallOpts, slotSet) } // GetDefaultSlotSetBid is a free data retrieval call binding the contract method 0x564e6a71. // // Solidity: function getDefaultSlotSetBid(uint8 slotSet) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetDefaultSlotSetBid(&_HermezAuctionProtocol.CallOpts, slotSet) +func (_Auction *AuctionCallerSession) GetDefaultSlotSetBid(slotSet uint8) (*big.Int, error) { + return _Auction.Contract.GetDefaultSlotSetBid(&_Auction.CallOpts, slotSet) } // GetDonationAddress is a free data retrieval call binding the contract method 0x54c03ab7. // // Solidity: function getDonationAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetDonationAddress(opts *bind.CallOpts) (common.Address, error) { +func (_Auction *AuctionCaller) GetDonationAddress(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getDonationAddress") + err := _Auction.contract.Call(opts, &out, "getDonationAddress") if err != nil { return *new(common.Address), err @@ -577,23 +577,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetDonationAddress(op // GetDonationAddress is a free data retrieval call binding the contract method 0x54c03ab7. // // Solidity: function getDonationAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetDonationAddress() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GetDonationAddress(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetDonationAddress() (common.Address, error) { + return _Auction.Contract.GetDonationAddress(&_Auction.CallOpts) } // GetDonationAddress is a free data retrieval call binding the contract method 0x54c03ab7. // // Solidity: function getDonationAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetDonationAddress() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GetDonationAddress(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetDonationAddress() (common.Address, error) { + return _Auction.Contract.GetDonationAddress(&_Auction.CallOpts) } // GetMinBidBySlot is a free data retrieval call binding the contract method 0x37d1bd0b. // // Solidity: function getMinBidBySlot(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetMinBidBySlot(opts *bind.CallOpts, slot *big.Int) (*big.Int, error) { +func (_Auction *AuctionCaller) GetMinBidBySlot(opts *bind.CallOpts, slot *big.Int) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getMinBidBySlot", slot) + err := _Auction.contract.Call(opts, &out, "getMinBidBySlot", slot) if err != nil { return *new(*big.Int), err @@ -608,23 +608,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetMinBidBySlot(opts // GetMinBidBySlot is a free data retrieval call binding the contract method 0x37d1bd0b. // // Solidity: function getMinBidBySlot(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetMinBidBySlot(slot *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetMinBidBySlot(&_HermezAuctionProtocol.CallOpts, slot) +func (_Auction *AuctionSession) GetMinBidBySlot(slot *big.Int) (*big.Int, error) { + return _Auction.Contract.GetMinBidBySlot(&_Auction.CallOpts, slot) } // GetMinBidBySlot is a free data retrieval call binding the contract method 0x37d1bd0b. // // Solidity: function getMinBidBySlot(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetMinBidBySlot(slot *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetMinBidBySlot(&_HermezAuctionProtocol.CallOpts, slot) +func (_Auction *AuctionCallerSession) GetMinBidBySlot(slot *big.Int) (*big.Int, error) { + return _Auction.Contract.GetMinBidBySlot(&_Auction.CallOpts, slot) } // GetOpenAuctionSlots is a free data retrieval call binding the contract method 0xac4b9012. // // Solidity: function getOpenAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetOpenAuctionSlots(opts *bind.CallOpts) (uint16, error) { +func (_Auction *AuctionCaller) GetOpenAuctionSlots(opts *bind.CallOpts) (uint16, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getOpenAuctionSlots") + err := _Auction.contract.Call(opts, &out, "getOpenAuctionSlots") if err != nil { return *new(uint16), err @@ -639,23 +639,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetOpenAuctionSlots(o // GetOpenAuctionSlots is a free data retrieval call binding the contract method 0xac4b9012. // // Solidity: function getOpenAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetOpenAuctionSlots() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetOpenAuctionSlots(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetOpenAuctionSlots() (uint16, error) { + return _Auction.Contract.GetOpenAuctionSlots(&_Auction.CallOpts) } // GetOpenAuctionSlots is a free data retrieval call binding the contract method 0xac4b9012. // // Solidity: function getOpenAuctionSlots() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetOpenAuctionSlots() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetOpenAuctionSlots(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetOpenAuctionSlots() (uint16, error) { + return _Auction.Contract.GetOpenAuctionSlots(&_Auction.CallOpts) } // GetOutbidding is a free data retrieval call binding the contract method 0x55b442e6. // // Solidity: function getOutbidding() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetOutbidding(opts *bind.CallOpts) (uint16, error) { +func (_Auction *AuctionCaller) GetOutbidding(opts *bind.CallOpts) (uint16, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getOutbidding") + err := _Auction.contract.Call(opts, &out, "getOutbidding") if err != nil { return *new(uint16), err @@ -670,23 +670,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetOutbidding(opts *b // GetOutbidding is a free data retrieval call binding the contract method 0x55b442e6. // // Solidity: function getOutbidding() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetOutbidding() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetOutbidding(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetOutbidding() (uint16, error) { + return _Auction.Contract.GetOutbidding(&_Auction.CallOpts) } // GetOutbidding is a free data retrieval call binding the contract method 0x55b442e6. // // Solidity: function getOutbidding() view returns(uint16) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetOutbidding() (uint16, error) { - return _HermezAuctionProtocol.Contract.GetOutbidding(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetOutbidding() (uint16, error) { + return _Auction.Contract.GetOutbidding(&_Auction.CallOpts) } // GetSlotDeadline is a free data retrieval call binding the contract method 0x13de9af2. // // Solidity: function getSlotDeadline() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotDeadline(opts *bind.CallOpts) (uint8, error) { +func (_Auction *AuctionCaller) GetSlotDeadline(opts *bind.CallOpts) (uint8, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getSlotDeadline") + err := _Auction.contract.Call(opts, &out, "getSlotDeadline") if err != nil { return *new(uint8), err @@ -701,23 +701,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotDeadline(opts // GetSlotDeadline is a free data retrieval call binding the contract method 0x13de9af2. // // Solidity: function getSlotDeadline() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetSlotDeadline() (uint8, error) { - return _HermezAuctionProtocol.Contract.GetSlotDeadline(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GetSlotDeadline() (uint8, error) { + return _Auction.Contract.GetSlotDeadline(&_Auction.CallOpts) } // GetSlotDeadline is a free data retrieval call binding the contract method 0x13de9af2. // // Solidity: function getSlotDeadline() view returns(uint8) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetSlotDeadline() (uint8, error) { - return _HermezAuctionProtocol.Contract.GetSlotDeadline(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GetSlotDeadline() (uint8, error) { + return _Auction.Contract.GetSlotDeadline(&_Auction.CallOpts) } // GetSlotNumber is a free data retrieval call binding the contract method 0xb3dc7bb1. // // Solidity: function getSlotNumber(uint128 blockNumber) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotNumber(opts *bind.CallOpts, blockNumber *big.Int) (*big.Int, error) { +func (_Auction *AuctionCaller) GetSlotNumber(opts *bind.CallOpts, blockNumber *big.Int) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getSlotNumber", blockNumber) + err := _Auction.contract.Call(opts, &out, "getSlotNumber", blockNumber) if err != nil { return *new(*big.Int), err @@ -732,23 +732,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotNumber(opts *b // GetSlotNumber is a free data retrieval call binding the contract method 0xb3dc7bb1. // // Solidity: function getSlotNumber(uint128 blockNumber) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetSlotNumber(blockNumber *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetSlotNumber(&_HermezAuctionProtocol.CallOpts, blockNumber) +func (_Auction *AuctionSession) GetSlotNumber(blockNumber *big.Int) (*big.Int, error) { + return _Auction.Contract.GetSlotNumber(&_Auction.CallOpts, blockNumber) } // GetSlotNumber is a free data retrieval call binding the contract method 0xb3dc7bb1. // // Solidity: function getSlotNumber(uint128 blockNumber) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetSlotNumber(blockNumber *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetSlotNumber(&_HermezAuctionProtocol.CallOpts, blockNumber) +func (_Auction *AuctionCallerSession) GetSlotNumber(blockNumber *big.Int) (*big.Int, error) { + return _Auction.Contract.GetSlotNumber(&_Auction.CallOpts, blockNumber) } // GetSlotSet is a free data retrieval call binding the contract method 0xac5f658b. // // Solidity: function getSlotSet(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotSet(opts *bind.CallOpts, slot *big.Int) (*big.Int, error) { +func (_Auction *AuctionCaller) GetSlotSet(opts *bind.CallOpts, slot *big.Int) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "getSlotSet", slot) + err := _Auction.contract.Call(opts, &out, "getSlotSet", slot) if err != nil { return *new(*big.Int), err @@ -763,23 +763,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GetSlotSet(opts *bind // GetSlotSet is a free data retrieval call binding the contract method 0xac5f658b. // // Solidity: function getSlotSet(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GetSlotSet(slot *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetSlotSet(&_HermezAuctionProtocol.CallOpts, slot) +func (_Auction *AuctionSession) GetSlotSet(slot *big.Int) (*big.Int, error) { + return _Auction.Contract.GetSlotSet(&_Auction.CallOpts, slot) } // GetSlotSet is a free data retrieval call binding the contract method 0xac5f658b. // // Solidity: function getSlotSet(uint128 slot) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GetSlotSet(slot *big.Int) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.GetSlotSet(&_HermezAuctionProtocol.CallOpts, slot) +func (_Auction *AuctionCallerSession) GetSlotSet(slot *big.Int) (*big.Int, error) { + return _Auction.Contract.GetSlotSet(&_Auction.CallOpts, slot) } // GovernanceAddress is a free data retrieval call binding the contract method 0x795053d3. // // Solidity: function governanceAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GovernanceAddress(opts *bind.CallOpts) (common.Address, error) { +func (_Auction *AuctionCaller) GovernanceAddress(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "governanceAddress") + err := _Auction.contract.Call(opts, &out, "governanceAddress") if err != nil { return *new(common.Address), err @@ -794,23 +794,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) GovernanceAddress(opt // GovernanceAddress is a free data retrieval call binding the contract method 0x795053d3. // // Solidity: function governanceAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) GovernanceAddress() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GovernanceAddress(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) GovernanceAddress() (common.Address, error) { + return _Auction.Contract.GovernanceAddress(&_Auction.CallOpts) } // GovernanceAddress is a free data retrieval call binding the contract method 0x795053d3. // // Solidity: function governanceAddress() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) GovernanceAddress() (common.Address, error) { - return _HermezAuctionProtocol.Contract.GovernanceAddress(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) GovernanceAddress() (common.Address, error) { + return _Auction.Contract.GovernanceAddress(&_Auction.CallOpts) } // HermezRollup is a free data retrieval call binding the contract method 0xaebd6d98. // // Solidity: function hermezRollup() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) HermezRollup(opts *bind.CallOpts) (common.Address, error) { +func (_Auction *AuctionCaller) HermezRollup(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "hermezRollup") + err := _Auction.contract.Call(opts, &out, "hermezRollup") if err != nil { return *new(common.Address), err @@ -825,23 +825,23 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) HermezRollup(opts *bi // HermezRollup is a free data retrieval call binding the contract method 0xaebd6d98. // // Solidity: function hermezRollup() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) HermezRollup() (common.Address, error) { - return _HermezAuctionProtocol.Contract.HermezRollup(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) HermezRollup() (common.Address, error) { + return _Auction.Contract.HermezRollup(&_Auction.CallOpts) } // HermezRollup is a free data retrieval call binding the contract method 0xaebd6d98. // // Solidity: function hermezRollup() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) HermezRollup() (common.Address, error) { - return _HermezAuctionProtocol.Contract.HermezRollup(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) HermezRollup() (common.Address, error) { + return _Auction.Contract.HermezRollup(&_Auction.CallOpts) } // PendingBalances is a free data retrieval call binding the contract method 0xecdae41b. // // Solidity: function pendingBalances(address ) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) PendingBalances(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { +func (_Auction *AuctionCaller) PendingBalances(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "pendingBalances", arg0) + err := _Auction.contract.Call(opts, &out, "pendingBalances", arg0) if err != nil { return *new(*big.Int), err @@ -856,21 +856,21 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) PendingBalances(opts // PendingBalances is a free data retrieval call binding the contract method 0xecdae41b. // // Solidity: function pendingBalances(address ) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) PendingBalances(arg0 common.Address) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.PendingBalances(&_HermezAuctionProtocol.CallOpts, arg0) +func (_Auction *AuctionSession) PendingBalances(arg0 common.Address) (*big.Int, error) { + return _Auction.Contract.PendingBalances(&_Auction.CallOpts, arg0) } // PendingBalances is a free data retrieval call binding the contract method 0xecdae41b. // // Solidity: function pendingBalances(address ) view returns(uint128) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) PendingBalances(arg0 common.Address) (*big.Int, error) { - return _HermezAuctionProtocol.Contract.PendingBalances(&_HermezAuctionProtocol.CallOpts, arg0) +func (_Auction *AuctionCallerSession) PendingBalances(arg0 common.Address) (*big.Int, error) { + return _Auction.Contract.PendingBalances(&_Auction.CallOpts, arg0) } // Slots is a free data retrieval call binding the contract method 0xbc415567. // // Solidity: function slots(uint128 ) view returns(address bidder, bool fulfilled, bool forgerCommitment, uint128 bidAmount, uint128 closedMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Slots(opts *bind.CallOpts, arg0 *big.Int) (struct { +func (_Auction *AuctionCaller) Slots(opts *bind.CallOpts, arg0 *big.Int) (struct { Bidder common.Address Fulfilled bool ForgerCommitment bool @@ -878,7 +878,7 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Slots(opts *bind.Call ClosedMinBid *big.Int }, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "slots", arg0) + err := _Auction.contract.Call(opts, &out, "slots", arg0) outstruct := new(struct { Bidder common.Address @@ -904,35 +904,35 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) Slots(opts *bind.Call // Slots is a free data retrieval call binding the contract method 0xbc415567. // // Solidity: function slots(uint128 ) view returns(address bidder, bool fulfilled, bool forgerCommitment, uint128 bidAmount, uint128 closedMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) Slots(arg0 *big.Int) (struct { +func (_Auction *AuctionSession) Slots(arg0 *big.Int) (struct { Bidder common.Address Fulfilled bool ForgerCommitment bool BidAmount *big.Int ClosedMinBid *big.Int }, error) { - return _HermezAuctionProtocol.Contract.Slots(&_HermezAuctionProtocol.CallOpts, arg0) + return _Auction.Contract.Slots(&_Auction.CallOpts, arg0) } // Slots is a free data retrieval call binding the contract method 0xbc415567. // // Solidity: function slots(uint128 ) view returns(address bidder, bool fulfilled, bool forgerCommitment, uint128 bidAmount, uint128 closedMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) Slots(arg0 *big.Int) (struct { +func (_Auction *AuctionCallerSession) Slots(arg0 *big.Int) (struct { Bidder common.Address Fulfilled bool ForgerCommitment bool BidAmount *big.Int ClosedMinBid *big.Int }, error) { - return _HermezAuctionProtocol.Contract.Slots(&_HermezAuctionProtocol.CallOpts, arg0) + return _Auction.Contract.Slots(&_Auction.CallOpts, arg0) } // TokenHEZ is a free data retrieval call binding the contract method 0x79a135e3. // // Solidity: function tokenHEZ() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) TokenHEZ(opts *bind.CallOpts) (common.Address, error) { +func (_Auction *AuctionCaller) TokenHEZ(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _HermezAuctionProtocol.contract.Call(opts, &out, "tokenHEZ") + err := _Auction.contract.Call(opts, &out, "tokenHEZ") if err != nil { return *new(common.Address), err @@ -947,335 +947,335 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolCaller) TokenHEZ(opts *bind.C // TokenHEZ is a free data retrieval call binding the contract method 0x79a135e3. // // Solidity: function tokenHEZ() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) TokenHEZ() (common.Address, error) { - return _HermezAuctionProtocol.Contract.TokenHEZ(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionSession) TokenHEZ() (common.Address, error) { + return _Auction.Contract.TokenHEZ(&_Auction.CallOpts) } // TokenHEZ is a free data retrieval call binding the contract method 0x79a135e3. // // Solidity: function tokenHEZ() view returns(address) -func (_HermezAuctionProtocol *HermezAuctionProtocolCallerSession) TokenHEZ() (common.Address, error) { - return _HermezAuctionProtocol.Contract.TokenHEZ(&_HermezAuctionProtocol.CallOpts) +func (_Auction *AuctionCallerSession) TokenHEZ() (common.Address, error) { + return _Auction.Contract.TokenHEZ(&_Auction.CallOpts) } // ChangeDefaultSlotSetBid is a paid mutator transaction binding the contract method 0x7c643b70. // // Solidity: function changeDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) ChangeDefaultSlotSetBid(opts *bind.TransactOpts, slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "changeDefaultSlotSetBid", slotSet, newInitialMinBid) +func (_Auction *AuctionTransactor) ChangeDefaultSlotSetBid(opts *bind.TransactOpts, slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "changeDefaultSlotSetBid", slotSet, newInitialMinBid) } // ChangeDefaultSlotSetBid is a paid mutator transaction binding the contract method 0x7c643b70. // // Solidity: function changeDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) ChangeDefaultSlotSetBid(slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ChangeDefaultSlotSetBid(&_HermezAuctionProtocol.TransactOpts, slotSet, newInitialMinBid) +func (_Auction *AuctionSession) ChangeDefaultSlotSetBid(slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { + return _Auction.Contract.ChangeDefaultSlotSetBid(&_Auction.TransactOpts, slotSet, newInitialMinBid) } // ChangeDefaultSlotSetBid is a paid mutator transaction binding the contract method 0x7c643b70. // // Solidity: function changeDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) ChangeDefaultSlotSetBid(slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ChangeDefaultSlotSetBid(&_HermezAuctionProtocol.TransactOpts, slotSet, newInitialMinBid) +func (_Auction *AuctionTransactorSession) ChangeDefaultSlotSetBid(slotSet *big.Int, newInitialMinBid *big.Int) (*types.Transaction, error) { + return _Auction.Contract.ChangeDefaultSlotSetBid(&_Auction.TransactOpts, slotSet, newInitialMinBid) } // ClaimHEZ is a paid mutator transaction binding the contract method 0x6dfe47c9. // // Solidity: function claimHEZ() returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) ClaimHEZ(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "claimHEZ") +func (_Auction *AuctionTransactor) ClaimHEZ(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "claimHEZ") } // ClaimHEZ is a paid mutator transaction binding the contract method 0x6dfe47c9. // // Solidity: function claimHEZ() returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) ClaimHEZ() (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ClaimHEZ(&_HermezAuctionProtocol.TransactOpts) +func (_Auction *AuctionSession) ClaimHEZ() (*types.Transaction, error) { + return _Auction.Contract.ClaimHEZ(&_Auction.TransactOpts) } // ClaimHEZ is a paid mutator transaction binding the contract method 0x6dfe47c9. // // Solidity: function claimHEZ() returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) ClaimHEZ() (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ClaimHEZ(&_HermezAuctionProtocol.TransactOpts) +func (_Auction *AuctionTransactorSession) ClaimHEZ() (*types.Transaction, error) { + return _Auction.Contract.ClaimHEZ(&_Auction.TransactOpts) } // ClaimPendingHEZ is a paid mutator transaction binding the contract method 0x41d42c23. // // Solidity: function claimPendingHEZ(uint128 slot) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) ClaimPendingHEZ(opts *bind.TransactOpts, slot *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "claimPendingHEZ", slot) +func (_Auction *AuctionTransactor) ClaimPendingHEZ(opts *bind.TransactOpts, slot *big.Int) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "claimPendingHEZ", slot) } // ClaimPendingHEZ is a paid mutator transaction binding the contract method 0x41d42c23. // // Solidity: function claimPendingHEZ(uint128 slot) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) ClaimPendingHEZ(slot *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ClaimPendingHEZ(&_HermezAuctionProtocol.TransactOpts, slot) +func (_Auction *AuctionSession) ClaimPendingHEZ(slot *big.Int) (*types.Transaction, error) { + return _Auction.Contract.ClaimPendingHEZ(&_Auction.TransactOpts, slot) } // ClaimPendingHEZ is a paid mutator transaction binding the contract method 0x41d42c23. // // Solidity: function claimPendingHEZ(uint128 slot) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) ClaimPendingHEZ(slot *big.Int) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ClaimPendingHEZ(&_HermezAuctionProtocol.TransactOpts, slot) +func (_Auction *AuctionTransactorSession) ClaimPendingHEZ(slot *big.Int) (*types.Transaction, error) { + return _Auction.Contract.ClaimPendingHEZ(&_Auction.TransactOpts, slot) } // Forge is a paid mutator transaction binding the contract method 0x4e5a5178. // // Solidity: function forge(address forger) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) Forge(opts *bind.TransactOpts, forger common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "forge", forger) +func (_Auction *AuctionTransactor) Forge(opts *bind.TransactOpts, forger common.Address) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "forge", forger) } // Forge is a paid mutator transaction binding the contract method 0x4e5a5178. // // Solidity: function forge(address forger) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) Forge(forger common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.Forge(&_HermezAuctionProtocol.TransactOpts, forger) +func (_Auction *AuctionSession) Forge(forger common.Address) (*types.Transaction, error) { + return _Auction.Contract.Forge(&_Auction.TransactOpts, forger) } // Forge is a paid mutator transaction binding the contract method 0x4e5a5178. // // Solidity: function forge(address forger) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) Forge(forger common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.Forge(&_HermezAuctionProtocol.TransactOpts, forger) +func (_Auction *AuctionTransactorSession) Forge(forger common.Address) (*types.Transaction, error) { + return _Auction.Contract.Forge(&_Auction.TransactOpts, forger) } // HermezAuctionProtocolInitializer is a paid mutator transaction binding the contract method 0x5e73a67f. // // Solidity: function hermezAuctionProtocolInitializer(address token, uint128 genesis, address hermezRollupAddress, address _governanceAddress, address donationAddress, address bootCoordinatorAddress, string _bootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) HermezAuctionProtocolInitializer(opts *bind.TransactOpts, token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "hermezAuctionProtocolInitializer", token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) +func (_Auction *AuctionTransactor) HermezAuctionProtocolInitializer(opts *bind.TransactOpts, token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "hermezAuctionProtocolInitializer", token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) } // HermezAuctionProtocolInitializer is a paid mutator transaction binding the contract method 0x5e73a67f. // // Solidity: function hermezAuctionProtocolInitializer(address token, uint128 genesis, address hermezRollupAddress, address _governanceAddress, address donationAddress, address bootCoordinatorAddress, string _bootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) HermezAuctionProtocolInitializer(token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.HermezAuctionProtocolInitializer(&_HermezAuctionProtocol.TransactOpts, token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) +func (_Auction *AuctionSession) HermezAuctionProtocolInitializer(token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.HermezAuctionProtocolInitializer(&_Auction.TransactOpts, token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) } // HermezAuctionProtocolInitializer is a paid mutator transaction binding the contract method 0x5e73a67f. // // Solidity: function hermezAuctionProtocolInitializer(address token, uint128 genesis, address hermezRollupAddress, address _governanceAddress, address donationAddress, address bootCoordinatorAddress, string _bootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) HermezAuctionProtocolInitializer(token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.HermezAuctionProtocolInitializer(&_HermezAuctionProtocol.TransactOpts, token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) +func (_Auction *AuctionTransactorSession) HermezAuctionProtocolInitializer(token common.Address, genesis *big.Int, hermezRollupAddress common.Address, _governanceAddress common.Address, donationAddress common.Address, bootCoordinatorAddress common.Address, _bootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.HermezAuctionProtocolInitializer(&_Auction.TransactOpts, token, genesis, hermezRollupAddress, _governanceAddress, donationAddress, bootCoordinatorAddress, _bootCoordinatorURL) } // ProcessBid is a paid mutator transaction binding the contract method 0x4b93b7fa. // // Solidity: function processBid(uint128 amount, uint128 slot, uint128 bidAmount, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) ProcessBid(opts *bind.TransactOpts, amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "processBid", amount, slot, bidAmount, permit) +func (_Auction *AuctionTransactor) ProcessBid(opts *bind.TransactOpts, amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "processBid", amount, slot, bidAmount, permit) } // ProcessBid is a paid mutator transaction binding the contract method 0x4b93b7fa. // // Solidity: function processBid(uint128 amount, uint128 slot, uint128 bidAmount, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) ProcessBid(amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ProcessBid(&_HermezAuctionProtocol.TransactOpts, amount, slot, bidAmount, permit) +func (_Auction *AuctionSession) ProcessBid(amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.Contract.ProcessBid(&_Auction.TransactOpts, amount, slot, bidAmount, permit) } // ProcessBid is a paid mutator transaction binding the contract method 0x4b93b7fa. // // Solidity: function processBid(uint128 amount, uint128 slot, uint128 bidAmount, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) ProcessBid(amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ProcessBid(&_HermezAuctionProtocol.TransactOpts, amount, slot, bidAmount, permit) +func (_Auction *AuctionTransactorSession) ProcessBid(amount *big.Int, slot *big.Int, bidAmount *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.Contract.ProcessBid(&_Auction.TransactOpts, amount, slot, bidAmount, permit) } // ProcessMultiBid is a paid mutator transaction binding the contract method 0x583ad0dd. // // Solidity: function processMultiBid(uint128 amount, uint128 startingSlot, uint128 endingSlot, bool[6] slotSets, uint128 maxBid, uint128 minBid, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) ProcessMultiBid(opts *bind.TransactOpts, amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "processMultiBid", amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) +func (_Auction *AuctionTransactor) ProcessMultiBid(opts *bind.TransactOpts, amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "processMultiBid", amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) } // ProcessMultiBid is a paid mutator transaction binding the contract method 0x583ad0dd. // // Solidity: function processMultiBid(uint128 amount, uint128 startingSlot, uint128 endingSlot, bool[6] slotSets, uint128 maxBid, uint128 minBid, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) ProcessMultiBid(amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ProcessMultiBid(&_HermezAuctionProtocol.TransactOpts, amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) +func (_Auction *AuctionSession) ProcessMultiBid(amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.Contract.ProcessMultiBid(&_Auction.TransactOpts, amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) } // ProcessMultiBid is a paid mutator transaction binding the contract method 0x583ad0dd. // // Solidity: function processMultiBid(uint128 amount, uint128 startingSlot, uint128 endingSlot, bool[6] slotSets, uint128 maxBid, uint128 minBid, bytes permit) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) ProcessMultiBid(amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.ProcessMultiBid(&_HermezAuctionProtocol.TransactOpts, amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) +func (_Auction *AuctionTransactorSession) ProcessMultiBid(amount *big.Int, startingSlot *big.Int, endingSlot *big.Int, slotSets [6]bool, maxBid *big.Int, minBid *big.Int, permit []byte) (*types.Transaction, error) { + return _Auction.Contract.ProcessMultiBid(&_Auction.TransactOpts, amount, startingSlot, endingSlot, slotSets, maxBid, minBid, permit) } // SetAllocationRatio is a paid mutator transaction binding the contract method 0x82787405. // // Solidity: function setAllocationRatio(uint16[3] newAllocationRatio) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetAllocationRatio(opts *bind.TransactOpts, newAllocationRatio [3]uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setAllocationRatio", newAllocationRatio) +func (_Auction *AuctionTransactor) SetAllocationRatio(opts *bind.TransactOpts, newAllocationRatio [3]uint16) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setAllocationRatio", newAllocationRatio) } // SetAllocationRatio is a paid mutator transaction binding the contract method 0x82787405. // // Solidity: function setAllocationRatio(uint16[3] newAllocationRatio) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetAllocationRatio(&_HermezAuctionProtocol.TransactOpts, newAllocationRatio) +func (_Auction *AuctionSession) SetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error) { + return _Auction.Contract.SetAllocationRatio(&_Auction.TransactOpts, newAllocationRatio) } // SetAllocationRatio is a paid mutator transaction binding the contract method 0x82787405. // // Solidity: function setAllocationRatio(uint16[3] newAllocationRatio) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetAllocationRatio(&_HermezAuctionProtocol.TransactOpts, newAllocationRatio) +func (_Auction *AuctionTransactorSession) SetAllocationRatio(newAllocationRatio [3]uint16) (*types.Transaction, error) { + return _Auction.Contract.SetAllocationRatio(&_Auction.TransactOpts, newAllocationRatio) } // SetBootCoordinator is a paid mutator transaction binding the contract method 0x6cbdc3df. // // Solidity: function setBootCoordinator(address newBootCoordinator, string newBootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetBootCoordinator(opts *bind.TransactOpts, newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setBootCoordinator", newBootCoordinator, newBootCoordinatorURL) +func (_Auction *AuctionTransactor) SetBootCoordinator(opts *bind.TransactOpts, newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setBootCoordinator", newBootCoordinator, newBootCoordinatorURL) } // SetBootCoordinator is a paid mutator transaction binding the contract method 0x6cbdc3df. // // Solidity: function setBootCoordinator(address newBootCoordinator, string newBootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetBootCoordinator(newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetBootCoordinator(&_HermezAuctionProtocol.TransactOpts, newBootCoordinator, newBootCoordinatorURL) +func (_Auction *AuctionSession) SetBootCoordinator(newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.SetBootCoordinator(&_Auction.TransactOpts, newBootCoordinator, newBootCoordinatorURL) } // SetBootCoordinator is a paid mutator transaction binding the contract method 0x6cbdc3df. // // Solidity: function setBootCoordinator(address newBootCoordinator, string newBootCoordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetBootCoordinator(newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetBootCoordinator(&_HermezAuctionProtocol.TransactOpts, newBootCoordinator, newBootCoordinatorURL) +func (_Auction *AuctionTransactorSession) SetBootCoordinator(newBootCoordinator common.Address, newBootCoordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.SetBootCoordinator(&_Auction.TransactOpts, newBootCoordinator, newBootCoordinatorURL) } // SetClosedAuctionSlots is a paid mutator transaction binding the contract method 0xd92bdda3. // // Solidity: function setClosedAuctionSlots(uint16 newClosedAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetClosedAuctionSlots(opts *bind.TransactOpts, newClosedAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setClosedAuctionSlots", newClosedAuctionSlots) +func (_Auction *AuctionTransactor) SetClosedAuctionSlots(opts *bind.TransactOpts, newClosedAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setClosedAuctionSlots", newClosedAuctionSlots) } // SetClosedAuctionSlots is a paid mutator transaction binding the contract method 0xd92bdda3. // // Solidity: function setClosedAuctionSlots(uint16 newClosedAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetClosedAuctionSlots(&_HermezAuctionProtocol.TransactOpts, newClosedAuctionSlots) +func (_Auction *AuctionSession) SetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.Contract.SetClosedAuctionSlots(&_Auction.TransactOpts, newClosedAuctionSlots) } // SetClosedAuctionSlots is a paid mutator transaction binding the contract method 0xd92bdda3. // // Solidity: function setClosedAuctionSlots(uint16 newClosedAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetClosedAuctionSlots(&_HermezAuctionProtocol.TransactOpts, newClosedAuctionSlots) +func (_Auction *AuctionTransactorSession) SetClosedAuctionSlots(newClosedAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.Contract.SetClosedAuctionSlots(&_Auction.TransactOpts, newClosedAuctionSlots) } // SetCoordinator is a paid mutator transaction binding the contract method 0x0eeaf080. // // Solidity: function setCoordinator(address forger, string coordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetCoordinator(opts *bind.TransactOpts, forger common.Address, coordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setCoordinator", forger, coordinatorURL) +func (_Auction *AuctionTransactor) SetCoordinator(opts *bind.TransactOpts, forger common.Address, coordinatorURL string) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setCoordinator", forger, coordinatorURL) } // SetCoordinator is a paid mutator transaction binding the contract method 0x0eeaf080. // // Solidity: function setCoordinator(address forger, string coordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetCoordinator(forger common.Address, coordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetCoordinator(&_HermezAuctionProtocol.TransactOpts, forger, coordinatorURL) +func (_Auction *AuctionSession) SetCoordinator(forger common.Address, coordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.SetCoordinator(&_Auction.TransactOpts, forger, coordinatorURL) } // SetCoordinator is a paid mutator transaction binding the contract method 0x0eeaf080. // // Solidity: function setCoordinator(address forger, string coordinatorURL) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetCoordinator(forger common.Address, coordinatorURL string) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetCoordinator(&_HermezAuctionProtocol.TransactOpts, forger, coordinatorURL) +func (_Auction *AuctionTransactorSession) SetCoordinator(forger common.Address, coordinatorURL string) (*types.Transaction, error) { + return _Auction.Contract.SetCoordinator(&_Auction.TransactOpts, forger, coordinatorURL) } // SetDonationAddress is a paid mutator transaction binding the contract method 0x6f48e79b. // // Solidity: function setDonationAddress(address newDonationAddress) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetDonationAddress(opts *bind.TransactOpts, newDonationAddress common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setDonationAddress", newDonationAddress) +func (_Auction *AuctionTransactor) SetDonationAddress(opts *bind.TransactOpts, newDonationAddress common.Address) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setDonationAddress", newDonationAddress) } // SetDonationAddress is a paid mutator transaction binding the contract method 0x6f48e79b. // // Solidity: function setDonationAddress(address newDonationAddress) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetDonationAddress(newDonationAddress common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetDonationAddress(&_HermezAuctionProtocol.TransactOpts, newDonationAddress) +func (_Auction *AuctionSession) SetDonationAddress(newDonationAddress common.Address) (*types.Transaction, error) { + return _Auction.Contract.SetDonationAddress(&_Auction.TransactOpts, newDonationAddress) } // SetDonationAddress is a paid mutator transaction binding the contract method 0x6f48e79b. // // Solidity: function setDonationAddress(address newDonationAddress) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetDonationAddress(newDonationAddress common.Address) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetDonationAddress(&_HermezAuctionProtocol.TransactOpts, newDonationAddress) +func (_Auction *AuctionTransactorSession) SetDonationAddress(newDonationAddress common.Address) (*types.Transaction, error) { + return _Auction.Contract.SetDonationAddress(&_Auction.TransactOpts, newDonationAddress) } // SetOpenAuctionSlots is a paid mutator transaction binding the contract method 0xc63de515. // // Solidity: function setOpenAuctionSlots(uint16 newOpenAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetOpenAuctionSlots(opts *bind.TransactOpts, newOpenAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setOpenAuctionSlots", newOpenAuctionSlots) +func (_Auction *AuctionTransactor) SetOpenAuctionSlots(opts *bind.TransactOpts, newOpenAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setOpenAuctionSlots", newOpenAuctionSlots) } // SetOpenAuctionSlots is a paid mutator transaction binding the contract method 0xc63de515. // // Solidity: function setOpenAuctionSlots(uint16 newOpenAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetOpenAuctionSlots(&_HermezAuctionProtocol.TransactOpts, newOpenAuctionSlots) +func (_Auction *AuctionSession) SetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.Contract.SetOpenAuctionSlots(&_Auction.TransactOpts, newOpenAuctionSlots) } // SetOpenAuctionSlots is a paid mutator transaction binding the contract method 0xc63de515. // // Solidity: function setOpenAuctionSlots(uint16 newOpenAuctionSlots) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetOpenAuctionSlots(&_HermezAuctionProtocol.TransactOpts, newOpenAuctionSlots) +func (_Auction *AuctionTransactorSession) SetOpenAuctionSlots(newOpenAuctionSlots uint16) (*types.Transaction, error) { + return _Auction.Contract.SetOpenAuctionSlots(&_Auction.TransactOpts, newOpenAuctionSlots) } // SetOutbidding is a paid mutator transaction binding the contract method 0xdfd5281b. // // Solidity: function setOutbidding(uint16 newOutbidding) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetOutbidding(opts *bind.TransactOpts, newOutbidding uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setOutbidding", newOutbidding) +func (_Auction *AuctionTransactor) SetOutbidding(opts *bind.TransactOpts, newOutbidding uint16) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setOutbidding", newOutbidding) } // SetOutbidding is a paid mutator transaction binding the contract method 0xdfd5281b. // // Solidity: function setOutbidding(uint16 newOutbidding) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetOutbidding(newOutbidding uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetOutbidding(&_HermezAuctionProtocol.TransactOpts, newOutbidding) +func (_Auction *AuctionSession) SetOutbidding(newOutbidding uint16) (*types.Transaction, error) { + return _Auction.Contract.SetOutbidding(&_Auction.TransactOpts, newOutbidding) } // SetOutbidding is a paid mutator transaction binding the contract method 0xdfd5281b. // // Solidity: function setOutbidding(uint16 newOutbidding) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetOutbidding(newOutbidding uint16) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetOutbidding(&_HermezAuctionProtocol.TransactOpts, newOutbidding) +func (_Auction *AuctionTransactorSession) SetOutbidding(newOutbidding uint16) (*types.Transaction, error) { + return _Auction.Contract.SetOutbidding(&_Auction.TransactOpts, newOutbidding) } // SetSlotDeadline is a paid mutator transaction binding the contract method 0x87e6b6bb. // // Solidity: function setSlotDeadline(uint8 newDeadline) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactor) SetSlotDeadline(opts *bind.TransactOpts, newDeadline uint8) (*types.Transaction, error) { - return _HermezAuctionProtocol.contract.Transact(opts, "setSlotDeadline", newDeadline) +func (_Auction *AuctionTransactor) SetSlotDeadline(opts *bind.TransactOpts, newDeadline uint8) (*types.Transaction, error) { + return _Auction.contract.Transact(opts, "setSlotDeadline", newDeadline) } // SetSlotDeadline is a paid mutator transaction binding the contract method 0x87e6b6bb. // // Solidity: function setSlotDeadline(uint8 newDeadline) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolSession) SetSlotDeadline(newDeadline uint8) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetSlotDeadline(&_HermezAuctionProtocol.TransactOpts, newDeadline) +func (_Auction *AuctionSession) SetSlotDeadline(newDeadline uint8) (*types.Transaction, error) { + return _Auction.Contract.SetSlotDeadline(&_Auction.TransactOpts, newDeadline) } // SetSlotDeadline is a paid mutator transaction binding the contract method 0x87e6b6bb. // // Solidity: function setSlotDeadline(uint8 newDeadline) returns() -func (_HermezAuctionProtocol *HermezAuctionProtocolTransactorSession) SetSlotDeadline(newDeadline uint8) (*types.Transaction, error) { - return _HermezAuctionProtocol.Contract.SetSlotDeadline(&_HermezAuctionProtocol.TransactOpts, newDeadline) +func (_Auction *AuctionTransactorSession) SetSlotDeadline(newDeadline uint8) (*types.Transaction, error) { + return _Auction.Contract.SetSlotDeadline(&_Auction.TransactOpts, newDeadline) } -// HermezAuctionProtocolHEZClaimedIterator is returned from FilterHEZClaimed and is used to iterate over the raw logs and unpacked data for HEZClaimed events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolHEZClaimedIterator struct { - Event *HermezAuctionProtocolHEZClaimed // Event containing the contract specifics and raw log +// AuctionHEZClaimedIterator is returned from FilterHEZClaimed and is used to iterate over the raw logs and unpacked data for HEZClaimed events raised by the Auction contract. +type AuctionHEZClaimedIterator struct { + Event *AuctionHEZClaimed // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1289,7 +1289,7 @@ type HermezAuctionProtocolHEZClaimedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolHEZClaimedIterator) Next() bool { +func (it *AuctionHEZClaimedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1298,7 +1298,7 @@ func (it *HermezAuctionProtocolHEZClaimedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolHEZClaimed) + it.Event = new(AuctionHEZClaimed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1313,7 +1313,7 @@ func (it *HermezAuctionProtocolHEZClaimedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolHEZClaimed) + it.Event = new(AuctionHEZClaimed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1329,19 +1329,19 @@ func (it *HermezAuctionProtocolHEZClaimedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolHEZClaimedIterator) Error() error { +func (it *AuctionHEZClaimedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolHEZClaimedIterator) Close() error { +func (it *AuctionHEZClaimedIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolHEZClaimed represents a HEZClaimed event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolHEZClaimed struct { +// AuctionHEZClaimed represents a HEZClaimed event raised by the Auction contract. +type AuctionHEZClaimed struct { Owner common.Address Amount *big.Int Raw types.Log // Blockchain specific contextual infos @@ -1350,31 +1350,31 @@ type HermezAuctionProtocolHEZClaimed struct { // FilterHEZClaimed is a free log retrieval operation binding the contract event 0x199ef0cb54d2b296ff6eaec2721bacf0ca3fd8344a43f5bdf4548b34dfa2594f. // // Solidity: event HEZClaimed(address indexed owner, uint128 amount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterHEZClaimed(opts *bind.FilterOpts, owner []common.Address) (*HermezAuctionProtocolHEZClaimedIterator, error) { +func (_Auction *AuctionFilterer) FilterHEZClaimed(opts *bind.FilterOpts, owner []common.Address) (*AuctionHEZClaimedIterator, error) { var ownerRule []interface{} for _, ownerItem := range owner { ownerRule = append(ownerRule, ownerItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "HEZClaimed", ownerRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "HEZClaimed", ownerRule) if err != nil { return nil, err } - return &HermezAuctionProtocolHEZClaimedIterator{contract: _HermezAuctionProtocol.contract, event: "HEZClaimed", logs: logs, sub: sub}, nil + return &AuctionHEZClaimedIterator{contract: _Auction.contract, event: "HEZClaimed", logs: logs, sub: sub}, nil } // WatchHEZClaimed is a free log subscription operation binding the contract event 0x199ef0cb54d2b296ff6eaec2721bacf0ca3fd8344a43f5bdf4548b34dfa2594f. // // Solidity: event HEZClaimed(address indexed owner, uint128 amount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchHEZClaimed(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolHEZClaimed, owner []common.Address) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchHEZClaimed(opts *bind.WatchOpts, sink chan<- *AuctionHEZClaimed, owner []common.Address) (event.Subscription, error) { var ownerRule []interface{} for _, ownerItem := range owner { ownerRule = append(ownerRule, ownerItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "HEZClaimed", ownerRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "HEZClaimed", ownerRule) if err != nil { return nil, err } @@ -1384,8 +1384,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchHEZClaimed(opt select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolHEZClaimed) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "HEZClaimed", log); err != nil { + event := new(AuctionHEZClaimed) + if err := _Auction.contract.UnpackLog(event, "HEZClaimed", log); err != nil { return err } event.Raw = log @@ -1409,18 +1409,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchHEZClaimed(opt // ParseHEZClaimed is a log parse operation binding the contract event 0x199ef0cb54d2b296ff6eaec2721bacf0ca3fd8344a43f5bdf4548b34dfa2594f. // // Solidity: event HEZClaimed(address indexed owner, uint128 amount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseHEZClaimed(log types.Log) (*HermezAuctionProtocolHEZClaimed, error) { - event := new(HermezAuctionProtocolHEZClaimed) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "HEZClaimed", log); err != nil { +func (_Auction *AuctionFilterer) ParseHEZClaimed(log types.Log) (*AuctionHEZClaimed, error) { + event := new(AuctionHEZClaimed) + if err := _Auction.contract.UnpackLog(event, "HEZClaimed", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator is returned from FilterInitializeHermezAuctionProtocolEvent and is used to iterate over the raw logs and unpacked data for InitializeHermezAuctionProtocolEvent events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator struct { - Event *HermezAuctionProtocolInitializeHermezAuctionProtocolEvent // Event containing the contract specifics and raw log +// AuctionInitializeHermezAuctionProtocolEventIterator is returned from FilterInitializeHermezAuctionProtocolEvent and is used to iterate over the raw logs and unpacked data for InitializeHermezAuctionProtocolEvent events raised by the Auction contract. +type AuctionInitializeHermezAuctionProtocolEventIterator struct { + Event *AuctionInitializeHermezAuctionProtocolEvent // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1434,7 +1434,7 @@ type HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Next() bool { +func (it *AuctionInitializeHermezAuctionProtocolEventIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1443,7 +1443,7 @@ func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Nex if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolInitializeHermezAuctionProtocolEvent) + it.Event = new(AuctionInitializeHermezAuctionProtocolEvent) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1458,7 +1458,7 @@ func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Nex // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolInitializeHermezAuctionProtocolEvent) + it.Event = new(AuctionInitializeHermezAuctionProtocolEvent) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1474,19 +1474,19 @@ func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Nex } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Error() error { +func (it *AuctionInitializeHermezAuctionProtocolEventIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator) Close() error { +func (it *AuctionInitializeHermezAuctionProtocolEventIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolInitializeHermezAuctionProtocolEvent represents a InitializeHermezAuctionProtocolEvent event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolInitializeHermezAuctionProtocolEvent struct { +// AuctionInitializeHermezAuctionProtocolEvent represents a InitializeHermezAuctionProtocolEvent event raised by the Auction contract. +type AuctionInitializeHermezAuctionProtocolEvent struct { DonationAddress common.Address BootCoordinatorAddress common.Address BootCoordinatorURL string @@ -1501,21 +1501,21 @@ type HermezAuctionProtocolInitializeHermezAuctionProtocolEvent struct { // FilterInitializeHermezAuctionProtocolEvent is a free log retrieval operation binding the contract event 0x9717e4e04c13817c600463a7a450110c754fd78758cdd538603f30528a24ce4b. // // Solidity: event InitializeHermezAuctionProtocolEvent(address donationAddress, address bootCoordinatorAddress, string bootCoordinatorURL, uint16 outbidding, uint8 slotDeadline, uint16 closedAuctionSlots, uint16 openAuctionSlots, uint16[3] allocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterInitializeHermezAuctionProtocolEvent(opts *bind.FilterOpts) (*HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator, error) { +func (_Auction *AuctionFilterer) FilterInitializeHermezAuctionProtocolEvent(opts *bind.FilterOpts) (*AuctionInitializeHermezAuctionProtocolEventIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "InitializeHermezAuctionProtocolEvent") + logs, sub, err := _Auction.contract.FilterLogs(opts, "InitializeHermezAuctionProtocolEvent") if err != nil { return nil, err } - return &HermezAuctionProtocolInitializeHermezAuctionProtocolEventIterator{contract: _HermezAuctionProtocol.contract, event: "InitializeHermezAuctionProtocolEvent", logs: logs, sub: sub}, nil + return &AuctionInitializeHermezAuctionProtocolEventIterator{contract: _Auction.contract, event: "InitializeHermezAuctionProtocolEvent", logs: logs, sub: sub}, nil } // WatchInitializeHermezAuctionProtocolEvent is a free log subscription operation binding the contract event 0x9717e4e04c13817c600463a7a450110c754fd78758cdd538603f30528a24ce4b. // // Solidity: event InitializeHermezAuctionProtocolEvent(address donationAddress, address bootCoordinatorAddress, string bootCoordinatorURL, uint16 outbidding, uint8 slotDeadline, uint16 closedAuctionSlots, uint16 openAuctionSlots, uint16[3] allocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchInitializeHermezAuctionProtocolEvent(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolInitializeHermezAuctionProtocolEvent) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchInitializeHermezAuctionProtocolEvent(opts *bind.WatchOpts, sink chan<- *AuctionInitializeHermezAuctionProtocolEvent) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "InitializeHermezAuctionProtocolEvent") + logs, sub, err := _Auction.contract.WatchLogs(opts, "InitializeHermezAuctionProtocolEvent") if err != nil { return nil, err } @@ -1525,8 +1525,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchInitializeHerm select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolInitializeHermezAuctionProtocolEvent) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "InitializeHermezAuctionProtocolEvent", log); err != nil { + event := new(AuctionInitializeHermezAuctionProtocolEvent) + if err := _Auction.contract.UnpackLog(event, "InitializeHermezAuctionProtocolEvent", log); err != nil { return err } event.Raw = log @@ -1550,18 +1550,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchInitializeHerm // ParseInitializeHermezAuctionProtocolEvent is a log parse operation binding the contract event 0x9717e4e04c13817c600463a7a450110c754fd78758cdd538603f30528a24ce4b. // // Solidity: event InitializeHermezAuctionProtocolEvent(address donationAddress, address bootCoordinatorAddress, string bootCoordinatorURL, uint16 outbidding, uint8 slotDeadline, uint16 closedAuctionSlots, uint16 openAuctionSlots, uint16[3] allocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseInitializeHermezAuctionProtocolEvent(log types.Log) (*HermezAuctionProtocolInitializeHermezAuctionProtocolEvent, error) { - event := new(HermezAuctionProtocolInitializeHermezAuctionProtocolEvent) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "InitializeHermezAuctionProtocolEvent", log); err != nil { +func (_Auction *AuctionFilterer) ParseInitializeHermezAuctionProtocolEvent(log types.Log) (*AuctionInitializeHermezAuctionProtocolEvent, error) { + event := new(AuctionInitializeHermezAuctionProtocolEvent) + if err := _Auction.contract.UnpackLog(event, "InitializeHermezAuctionProtocolEvent", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewAllocationRatioIterator is returned from FilterNewAllocationRatio and is used to iterate over the raw logs and unpacked data for NewAllocationRatio events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewAllocationRatioIterator struct { - Event *HermezAuctionProtocolNewAllocationRatio // Event containing the contract specifics and raw log +// AuctionNewAllocationRatioIterator is returned from FilterNewAllocationRatio and is used to iterate over the raw logs and unpacked data for NewAllocationRatio events raised by the Auction contract. +type AuctionNewAllocationRatioIterator struct { + Event *AuctionNewAllocationRatio // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1575,7 +1575,7 @@ type HermezAuctionProtocolNewAllocationRatioIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewAllocationRatioIterator) Next() bool { +func (it *AuctionNewAllocationRatioIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1584,7 +1584,7 @@ func (it *HermezAuctionProtocolNewAllocationRatioIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewAllocationRatio) + it.Event = new(AuctionNewAllocationRatio) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1599,7 +1599,7 @@ func (it *HermezAuctionProtocolNewAllocationRatioIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewAllocationRatio) + it.Event = new(AuctionNewAllocationRatio) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1615,19 +1615,19 @@ func (it *HermezAuctionProtocolNewAllocationRatioIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewAllocationRatioIterator) Error() error { +func (it *AuctionNewAllocationRatioIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewAllocationRatioIterator) Close() error { +func (it *AuctionNewAllocationRatioIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewAllocationRatio represents a NewAllocationRatio event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewAllocationRatio struct { +// AuctionNewAllocationRatio represents a NewAllocationRatio event raised by the Auction contract. +type AuctionNewAllocationRatio struct { NewAllocationRatio [3]uint16 Raw types.Log // Blockchain specific contextual infos } @@ -1635,21 +1635,21 @@ type HermezAuctionProtocolNewAllocationRatio struct { // FilterNewAllocationRatio is a free log retrieval operation binding the contract event 0x0bb59eceb12f1bdb63e4a7d57c70d6473fefd7c3f51af5a3604f7e97197073e4. // // Solidity: event NewAllocationRatio(uint16[3] newAllocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewAllocationRatio(opts *bind.FilterOpts) (*HermezAuctionProtocolNewAllocationRatioIterator, error) { +func (_Auction *AuctionFilterer) FilterNewAllocationRatio(opts *bind.FilterOpts) (*AuctionNewAllocationRatioIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewAllocationRatio") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewAllocationRatio") if err != nil { return nil, err } - return &HermezAuctionProtocolNewAllocationRatioIterator{contract: _HermezAuctionProtocol.contract, event: "NewAllocationRatio", logs: logs, sub: sub}, nil + return &AuctionNewAllocationRatioIterator{contract: _Auction.contract, event: "NewAllocationRatio", logs: logs, sub: sub}, nil } // WatchNewAllocationRatio is a free log subscription operation binding the contract event 0x0bb59eceb12f1bdb63e4a7d57c70d6473fefd7c3f51af5a3604f7e97197073e4. // // Solidity: event NewAllocationRatio(uint16[3] newAllocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewAllocationRatio(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewAllocationRatio) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewAllocationRatio(opts *bind.WatchOpts, sink chan<- *AuctionNewAllocationRatio) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewAllocationRatio") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewAllocationRatio") if err != nil { return nil, err } @@ -1659,8 +1659,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewAllocationR select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewAllocationRatio) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewAllocationRatio", log); err != nil { + event := new(AuctionNewAllocationRatio) + if err := _Auction.contract.UnpackLog(event, "NewAllocationRatio", log); err != nil { return err } event.Raw = log @@ -1684,18 +1684,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewAllocationR // ParseNewAllocationRatio is a log parse operation binding the contract event 0x0bb59eceb12f1bdb63e4a7d57c70d6473fefd7c3f51af5a3604f7e97197073e4. // // Solidity: event NewAllocationRatio(uint16[3] newAllocationRatio) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewAllocationRatio(log types.Log) (*HermezAuctionProtocolNewAllocationRatio, error) { - event := new(HermezAuctionProtocolNewAllocationRatio) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewAllocationRatio", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewAllocationRatio(log types.Log) (*AuctionNewAllocationRatio, error) { + event := new(AuctionNewAllocationRatio) + if err := _Auction.contract.UnpackLog(event, "NewAllocationRatio", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewBidIterator is returned from FilterNewBid and is used to iterate over the raw logs and unpacked data for NewBid events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewBidIterator struct { - Event *HermezAuctionProtocolNewBid // Event containing the contract specifics and raw log +// AuctionNewBidIterator is returned from FilterNewBid and is used to iterate over the raw logs and unpacked data for NewBid events raised by the Auction contract. +type AuctionNewBidIterator struct { + Event *AuctionNewBid // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1709,7 +1709,7 @@ type HermezAuctionProtocolNewBidIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewBidIterator) Next() bool { +func (it *AuctionNewBidIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1718,7 +1718,7 @@ func (it *HermezAuctionProtocolNewBidIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewBid) + it.Event = new(AuctionNewBid) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1733,7 +1733,7 @@ func (it *HermezAuctionProtocolNewBidIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewBid) + it.Event = new(AuctionNewBid) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1749,19 +1749,19 @@ func (it *HermezAuctionProtocolNewBidIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewBidIterator) Error() error { +func (it *AuctionNewBidIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewBidIterator) Close() error { +func (it *AuctionNewBidIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewBid represents a NewBid event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewBid struct { +// AuctionNewBid represents a NewBid event raised by the Auction contract. +type AuctionNewBid struct { Slot *big.Int BidAmount *big.Int Bidder common.Address @@ -1771,7 +1771,7 @@ type HermezAuctionProtocolNewBid struct { // FilterNewBid is a free log retrieval operation binding the contract event 0xd48e8329cdb2fb109b4fe445d7b681a74b256bff16e6f7f33b9d4fbe9038e433. // // Solidity: event NewBid(uint128 indexed slot, uint128 bidAmount, address indexed bidder) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewBid(opts *bind.FilterOpts, slot []*big.Int, bidder []common.Address) (*HermezAuctionProtocolNewBidIterator, error) { +func (_Auction *AuctionFilterer) FilterNewBid(opts *bind.FilterOpts, slot []*big.Int, bidder []common.Address) (*AuctionNewBidIterator, error) { var slotRule []interface{} for _, slotItem := range slot { @@ -1783,17 +1783,17 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewBid(opts * bidderRule = append(bidderRule, bidderItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewBid", slotRule, bidderRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewBid", slotRule, bidderRule) if err != nil { return nil, err } - return &HermezAuctionProtocolNewBidIterator{contract: _HermezAuctionProtocol.contract, event: "NewBid", logs: logs, sub: sub}, nil + return &AuctionNewBidIterator{contract: _Auction.contract, event: "NewBid", logs: logs, sub: sub}, nil } // WatchNewBid is a free log subscription operation binding the contract event 0xd48e8329cdb2fb109b4fe445d7b681a74b256bff16e6f7f33b9d4fbe9038e433. // // Solidity: event NewBid(uint128 indexed slot, uint128 bidAmount, address indexed bidder) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBid(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewBid, slot []*big.Int, bidder []common.Address) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewBid(opts *bind.WatchOpts, sink chan<- *AuctionNewBid, slot []*big.Int, bidder []common.Address) (event.Subscription, error) { var slotRule []interface{} for _, slotItem := range slot { @@ -1805,7 +1805,7 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBid(opts *b bidderRule = append(bidderRule, bidderItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewBid", slotRule, bidderRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewBid", slotRule, bidderRule) if err != nil { return nil, err } @@ -1815,8 +1815,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBid(opts *b select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewBid) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewBid", log); err != nil { + event := new(AuctionNewBid) + if err := _Auction.contract.UnpackLog(event, "NewBid", log); err != nil { return err } event.Raw = log @@ -1840,18 +1840,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBid(opts *b // ParseNewBid is a log parse operation binding the contract event 0xd48e8329cdb2fb109b4fe445d7b681a74b256bff16e6f7f33b9d4fbe9038e433. // // Solidity: event NewBid(uint128 indexed slot, uint128 bidAmount, address indexed bidder) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewBid(log types.Log) (*HermezAuctionProtocolNewBid, error) { - event := new(HermezAuctionProtocolNewBid) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewBid", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewBid(log types.Log) (*AuctionNewBid, error) { + event := new(AuctionNewBid) + if err := _Auction.contract.UnpackLog(event, "NewBid", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewBootCoordinatorIterator is returned from FilterNewBootCoordinator and is used to iterate over the raw logs and unpacked data for NewBootCoordinator events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewBootCoordinatorIterator struct { - Event *HermezAuctionProtocolNewBootCoordinator // Event containing the contract specifics and raw log +// AuctionNewBootCoordinatorIterator is returned from FilterNewBootCoordinator and is used to iterate over the raw logs and unpacked data for NewBootCoordinator events raised by the Auction contract. +type AuctionNewBootCoordinatorIterator struct { + Event *AuctionNewBootCoordinator // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1865,7 +1865,7 @@ type HermezAuctionProtocolNewBootCoordinatorIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Next() bool { +func (it *AuctionNewBootCoordinatorIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1874,7 +1874,7 @@ func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewBootCoordinator) + it.Event = new(AuctionNewBootCoordinator) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1889,7 +1889,7 @@ func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewBootCoordinator) + it.Event = new(AuctionNewBootCoordinator) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1905,19 +1905,19 @@ func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Error() error { +func (it *AuctionNewBootCoordinatorIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewBootCoordinatorIterator) Close() error { +func (it *AuctionNewBootCoordinatorIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewBootCoordinator represents a NewBootCoordinator event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewBootCoordinator struct { +// AuctionNewBootCoordinator represents a NewBootCoordinator event raised by the Auction contract. +type AuctionNewBootCoordinator struct { NewBootCoordinator common.Address NewBootCoordinatorURL string Raw types.Log // Blockchain specific contextual infos @@ -1926,31 +1926,31 @@ type HermezAuctionProtocolNewBootCoordinator struct { // FilterNewBootCoordinator is a free log retrieval operation binding the contract event 0x0487eab4c1da34bf653268e33bee8bfec7dacfd6f3226047197ebf872293cfd6. // // Solidity: event NewBootCoordinator(address indexed newBootCoordinator, string newBootCoordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewBootCoordinator(opts *bind.FilterOpts, newBootCoordinator []common.Address) (*HermezAuctionProtocolNewBootCoordinatorIterator, error) { +func (_Auction *AuctionFilterer) FilterNewBootCoordinator(opts *bind.FilterOpts, newBootCoordinator []common.Address) (*AuctionNewBootCoordinatorIterator, error) { var newBootCoordinatorRule []interface{} for _, newBootCoordinatorItem := range newBootCoordinator { newBootCoordinatorRule = append(newBootCoordinatorRule, newBootCoordinatorItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewBootCoordinator", newBootCoordinatorRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewBootCoordinator", newBootCoordinatorRule) if err != nil { return nil, err } - return &HermezAuctionProtocolNewBootCoordinatorIterator{contract: _HermezAuctionProtocol.contract, event: "NewBootCoordinator", logs: logs, sub: sub}, nil + return &AuctionNewBootCoordinatorIterator{contract: _Auction.contract, event: "NewBootCoordinator", logs: logs, sub: sub}, nil } // WatchNewBootCoordinator is a free log subscription operation binding the contract event 0x0487eab4c1da34bf653268e33bee8bfec7dacfd6f3226047197ebf872293cfd6. // // Solidity: event NewBootCoordinator(address indexed newBootCoordinator, string newBootCoordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBootCoordinator(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewBootCoordinator, newBootCoordinator []common.Address) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewBootCoordinator(opts *bind.WatchOpts, sink chan<- *AuctionNewBootCoordinator, newBootCoordinator []common.Address) (event.Subscription, error) { var newBootCoordinatorRule []interface{} for _, newBootCoordinatorItem := range newBootCoordinator { newBootCoordinatorRule = append(newBootCoordinatorRule, newBootCoordinatorItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewBootCoordinator", newBootCoordinatorRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewBootCoordinator", newBootCoordinatorRule) if err != nil { return nil, err } @@ -1960,8 +1960,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBootCoordin select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewBootCoordinator) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewBootCoordinator", log); err != nil { + event := new(AuctionNewBootCoordinator) + if err := _Auction.contract.UnpackLog(event, "NewBootCoordinator", log); err != nil { return err } event.Raw = log @@ -1985,18 +1985,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewBootCoordin // ParseNewBootCoordinator is a log parse operation binding the contract event 0x0487eab4c1da34bf653268e33bee8bfec7dacfd6f3226047197ebf872293cfd6. // // Solidity: event NewBootCoordinator(address indexed newBootCoordinator, string newBootCoordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewBootCoordinator(log types.Log) (*HermezAuctionProtocolNewBootCoordinator, error) { - event := new(HermezAuctionProtocolNewBootCoordinator) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewBootCoordinator", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewBootCoordinator(log types.Log) (*AuctionNewBootCoordinator, error) { + event := new(AuctionNewBootCoordinator) + if err := _Auction.contract.UnpackLog(event, "NewBootCoordinator", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewClosedAuctionSlotsIterator is returned from FilterNewClosedAuctionSlots and is used to iterate over the raw logs and unpacked data for NewClosedAuctionSlots events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewClosedAuctionSlotsIterator struct { - Event *HermezAuctionProtocolNewClosedAuctionSlots // Event containing the contract specifics and raw log +// AuctionNewClosedAuctionSlotsIterator is returned from FilterNewClosedAuctionSlots and is used to iterate over the raw logs and unpacked data for NewClosedAuctionSlots events raised by the Auction contract. +type AuctionNewClosedAuctionSlotsIterator struct { + Event *AuctionNewClosedAuctionSlots // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2010,7 +2010,7 @@ type HermezAuctionProtocolNewClosedAuctionSlotsIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Next() bool { +func (it *AuctionNewClosedAuctionSlotsIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2019,7 +2019,7 @@ func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewClosedAuctionSlots) + it.Event = new(AuctionNewClosedAuctionSlots) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2034,7 +2034,7 @@ func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewClosedAuctionSlots) + it.Event = new(AuctionNewClosedAuctionSlots) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2050,19 +2050,19 @@ func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Error() error { +func (it *AuctionNewClosedAuctionSlotsIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewClosedAuctionSlotsIterator) Close() error { +func (it *AuctionNewClosedAuctionSlotsIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewClosedAuctionSlots represents a NewClosedAuctionSlots event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewClosedAuctionSlots struct { +// AuctionNewClosedAuctionSlots represents a NewClosedAuctionSlots event raised by the Auction contract. +type AuctionNewClosedAuctionSlots struct { NewClosedAuctionSlots uint16 Raw types.Log // Blockchain specific contextual infos } @@ -2070,21 +2070,21 @@ type HermezAuctionProtocolNewClosedAuctionSlots struct { // FilterNewClosedAuctionSlots is a free log retrieval operation binding the contract event 0xc78051d3757db196b1e445f3a9a1380944518c69b5d7922ec747c54f0340a4ea. // // Solidity: event NewClosedAuctionSlots(uint16 newClosedAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewClosedAuctionSlots(opts *bind.FilterOpts) (*HermezAuctionProtocolNewClosedAuctionSlotsIterator, error) { +func (_Auction *AuctionFilterer) FilterNewClosedAuctionSlots(opts *bind.FilterOpts) (*AuctionNewClosedAuctionSlotsIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewClosedAuctionSlots") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewClosedAuctionSlots") if err != nil { return nil, err } - return &HermezAuctionProtocolNewClosedAuctionSlotsIterator{contract: _HermezAuctionProtocol.contract, event: "NewClosedAuctionSlots", logs: logs, sub: sub}, nil + return &AuctionNewClosedAuctionSlotsIterator{contract: _Auction.contract, event: "NewClosedAuctionSlots", logs: logs, sub: sub}, nil } // WatchNewClosedAuctionSlots is a free log subscription operation binding the contract event 0xc78051d3757db196b1e445f3a9a1380944518c69b5d7922ec747c54f0340a4ea. // // Solidity: event NewClosedAuctionSlots(uint16 newClosedAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewClosedAuctionSlots(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewClosedAuctionSlots) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewClosedAuctionSlots(opts *bind.WatchOpts, sink chan<- *AuctionNewClosedAuctionSlots) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewClosedAuctionSlots") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewClosedAuctionSlots") if err != nil { return nil, err } @@ -2094,8 +2094,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewClosedAucti select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewClosedAuctionSlots) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewClosedAuctionSlots", log); err != nil { + event := new(AuctionNewClosedAuctionSlots) + if err := _Auction.contract.UnpackLog(event, "NewClosedAuctionSlots", log); err != nil { return err } event.Raw = log @@ -2119,18 +2119,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewClosedAucti // ParseNewClosedAuctionSlots is a log parse operation binding the contract event 0xc78051d3757db196b1e445f3a9a1380944518c69b5d7922ec747c54f0340a4ea. // // Solidity: event NewClosedAuctionSlots(uint16 newClosedAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewClosedAuctionSlots(log types.Log) (*HermezAuctionProtocolNewClosedAuctionSlots, error) { - event := new(HermezAuctionProtocolNewClosedAuctionSlots) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewClosedAuctionSlots", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewClosedAuctionSlots(log types.Log) (*AuctionNewClosedAuctionSlots, error) { + event := new(AuctionNewClosedAuctionSlots) + if err := _Auction.contract.UnpackLog(event, "NewClosedAuctionSlots", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewDefaultSlotSetBidIterator is returned from FilterNewDefaultSlotSetBid and is used to iterate over the raw logs and unpacked data for NewDefaultSlotSetBid events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewDefaultSlotSetBidIterator struct { - Event *HermezAuctionProtocolNewDefaultSlotSetBid // Event containing the contract specifics and raw log +// AuctionNewDefaultSlotSetBidIterator is returned from FilterNewDefaultSlotSetBid and is used to iterate over the raw logs and unpacked data for NewDefaultSlotSetBid events raised by the Auction contract. +type AuctionNewDefaultSlotSetBidIterator struct { + Event *AuctionNewDefaultSlotSetBid // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2144,7 +2144,7 @@ type HermezAuctionProtocolNewDefaultSlotSetBidIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Next() bool { +func (it *AuctionNewDefaultSlotSetBidIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2153,7 +2153,7 @@ func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewDefaultSlotSetBid) + it.Event = new(AuctionNewDefaultSlotSetBid) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2168,7 +2168,7 @@ func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewDefaultSlotSetBid) + it.Event = new(AuctionNewDefaultSlotSetBid) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2184,19 +2184,19 @@ func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Error() error { +func (it *AuctionNewDefaultSlotSetBidIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewDefaultSlotSetBidIterator) Close() error { +func (it *AuctionNewDefaultSlotSetBidIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewDefaultSlotSetBid represents a NewDefaultSlotSetBid event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewDefaultSlotSetBid struct { +// AuctionNewDefaultSlotSetBid represents a NewDefaultSlotSetBid event raised by the Auction contract. +type AuctionNewDefaultSlotSetBid struct { SlotSet *big.Int NewInitialMinBid *big.Int Raw types.Log // Blockchain specific contextual infos @@ -2205,21 +2205,21 @@ type HermezAuctionProtocolNewDefaultSlotSetBid struct { // FilterNewDefaultSlotSetBid is a free log retrieval operation binding the contract event 0xa922aa010d1ff8e70b2aa9247d891836795c3d3ba2a543c37c91a44dc4a50172. // // Solidity: event NewDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewDefaultSlotSetBid(opts *bind.FilterOpts) (*HermezAuctionProtocolNewDefaultSlotSetBidIterator, error) { +func (_Auction *AuctionFilterer) FilterNewDefaultSlotSetBid(opts *bind.FilterOpts) (*AuctionNewDefaultSlotSetBidIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewDefaultSlotSetBid") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewDefaultSlotSetBid") if err != nil { return nil, err } - return &HermezAuctionProtocolNewDefaultSlotSetBidIterator{contract: _HermezAuctionProtocol.contract, event: "NewDefaultSlotSetBid", logs: logs, sub: sub}, nil + return &AuctionNewDefaultSlotSetBidIterator{contract: _Auction.contract, event: "NewDefaultSlotSetBid", logs: logs, sub: sub}, nil } // WatchNewDefaultSlotSetBid is a free log subscription operation binding the contract event 0xa922aa010d1ff8e70b2aa9247d891836795c3d3ba2a543c37c91a44dc4a50172. // // Solidity: event NewDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDefaultSlotSetBid(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewDefaultSlotSetBid) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewDefaultSlotSetBid(opts *bind.WatchOpts, sink chan<- *AuctionNewDefaultSlotSetBid) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewDefaultSlotSetBid") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewDefaultSlotSetBid") if err != nil { return nil, err } @@ -2229,8 +2229,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDefaultSlot select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewDefaultSlotSetBid) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewDefaultSlotSetBid", log); err != nil { + event := new(AuctionNewDefaultSlotSetBid) + if err := _Auction.contract.UnpackLog(event, "NewDefaultSlotSetBid", log); err != nil { return err } event.Raw = log @@ -2254,18 +2254,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDefaultSlot // ParseNewDefaultSlotSetBid is a log parse operation binding the contract event 0xa922aa010d1ff8e70b2aa9247d891836795c3d3ba2a543c37c91a44dc4a50172. // // Solidity: event NewDefaultSlotSetBid(uint128 slotSet, uint128 newInitialMinBid) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewDefaultSlotSetBid(log types.Log) (*HermezAuctionProtocolNewDefaultSlotSetBid, error) { - event := new(HermezAuctionProtocolNewDefaultSlotSetBid) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewDefaultSlotSetBid", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewDefaultSlotSetBid(log types.Log) (*AuctionNewDefaultSlotSetBid, error) { + event := new(AuctionNewDefaultSlotSetBid) + if err := _Auction.contract.UnpackLog(event, "NewDefaultSlotSetBid", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewDonationAddressIterator is returned from FilterNewDonationAddress and is used to iterate over the raw logs and unpacked data for NewDonationAddress events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewDonationAddressIterator struct { - Event *HermezAuctionProtocolNewDonationAddress // Event containing the contract specifics and raw log +// AuctionNewDonationAddressIterator is returned from FilterNewDonationAddress and is used to iterate over the raw logs and unpacked data for NewDonationAddress events raised by the Auction contract. +type AuctionNewDonationAddressIterator struct { + Event *AuctionNewDonationAddress // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2279,7 +2279,7 @@ type HermezAuctionProtocolNewDonationAddressIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewDonationAddressIterator) Next() bool { +func (it *AuctionNewDonationAddressIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2288,7 +2288,7 @@ func (it *HermezAuctionProtocolNewDonationAddressIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewDonationAddress) + it.Event = new(AuctionNewDonationAddress) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2303,7 +2303,7 @@ func (it *HermezAuctionProtocolNewDonationAddressIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewDonationAddress) + it.Event = new(AuctionNewDonationAddress) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2319,19 +2319,19 @@ func (it *HermezAuctionProtocolNewDonationAddressIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewDonationAddressIterator) Error() error { +func (it *AuctionNewDonationAddressIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewDonationAddressIterator) Close() error { +func (it *AuctionNewDonationAddressIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewDonationAddress represents a NewDonationAddress event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewDonationAddress struct { +// AuctionNewDonationAddress represents a NewDonationAddress event raised by the Auction contract. +type AuctionNewDonationAddress struct { NewDonationAddress common.Address Raw types.Log // Blockchain specific contextual infos } @@ -2339,31 +2339,31 @@ type HermezAuctionProtocolNewDonationAddress struct { // FilterNewDonationAddress is a free log retrieval operation binding the contract event 0xa62863cbad1647a2855e9cd39d04fa6dfd32e1b9cfaff1aaf6523f4aaafeccd7. // // Solidity: event NewDonationAddress(address indexed newDonationAddress) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewDonationAddress(opts *bind.FilterOpts, newDonationAddress []common.Address) (*HermezAuctionProtocolNewDonationAddressIterator, error) { +func (_Auction *AuctionFilterer) FilterNewDonationAddress(opts *bind.FilterOpts, newDonationAddress []common.Address) (*AuctionNewDonationAddressIterator, error) { var newDonationAddressRule []interface{} for _, newDonationAddressItem := range newDonationAddress { newDonationAddressRule = append(newDonationAddressRule, newDonationAddressItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewDonationAddress", newDonationAddressRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewDonationAddress", newDonationAddressRule) if err != nil { return nil, err } - return &HermezAuctionProtocolNewDonationAddressIterator{contract: _HermezAuctionProtocol.contract, event: "NewDonationAddress", logs: logs, sub: sub}, nil + return &AuctionNewDonationAddressIterator{contract: _Auction.contract, event: "NewDonationAddress", logs: logs, sub: sub}, nil } // WatchNewDonationAddress is a free log subscription operation binding the contract event 0xa62863cbad1647a2855e9cd39d04fa6dfd32e1b9cfaff1aaf6523f4aaafeccd7. // // Solidity: event NewDonationAddress(address indexed newDonationAddress) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDonationAddress(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewDonationAddress, newDonationAddress []common.Address) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewDonationAddress(opts *bind.WatchOpts, sink chan<- *AuctionNewDonationAddress, newDonationAddress []common.Address) (event.Subscription, error) { var newDonationAddressRule []interface{} for _, newDonationAddressItem := range newDonationAddress { newDonationAddressRule = append(newDonationAddressRule, newDonationAddressItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewDonationAddress", newDonationAddressRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewDonationAddress", newDonationAddressRule) if err != nil { return nil, err } @@ -2373,8 +2373,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDonationAdd select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewDonationAddress) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewDonationAddress", log); err != nil { + event := new(AuctionNewDonationAddress) + if err := _Auction.contract.UnpackLog(event, "NewDonationAddress", log); err != nil { return err } event.Raw = log @@ -2398,18 +2398,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewDonationAdd // ParseNewDonationAddress is a log parse operation binding the contract event 0xa62863cbad1647a2855e9cd39d04fa6dfd32e1b9cfaff1aaf6523f4aaafeccd7. // // Solidity: event NewDonationAddress(address indexed newDonationAddress) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewDonationAddress(log types.Log) (*HermezAuctionProtocolNewDonationAddress, error) { - event := new(HermezAuctionProtocolNewDonationAddress) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewDonationAddress", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewDonationAddress(log types.Log) (*AuctionNewDonationAddress, error) { + event := new(AuctionNewDonationAddress) + if err := _Auction.contract.UnpackLog(event, "NewDonationAddress", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewForgeIterator is returned from FilterNewForge and is used to iterate over the raw logs and unpacked data for NewForge events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewForgeIterator struct { - Event *HermezAuctionProtocolNewForge // Event containing the contract specifics and raw log +// AuctionNewForgeIterator is returned from FilterNewForge and is used to iterate over the raw logs and unpacked data for NewForge events raised by the Auction contract. +type AuctionNewForgeIterator struct { + Event *AuctionNewForge // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2423,7 +2423,7 @@ type HermezAuctionProtocolNewForgeIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewForgeIterator) Next() bool { +func (it *AuctionNewForgeIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2432,7 +2432,7 @@ func (it *HermezAuctionProtocolNewForgeIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewForge) + it.Event = new(AuctionNewForge) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2447,7 +2447,7 @@ func (it *HermezAuctionProtocolNewForgeIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewForge) + it.Event = new(AuctionNewForge) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2463,19 +2463,19 @@ func (it *HermezAuctionProtocolNewForgeIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewForgeIterator) Error() error { +func (it *AuctionNewForgeIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewForgeIterator) Close() error { +func (it *AuctionNewForgeIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewForge represents a NewForge event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewForge struct { +// AuctionNewForge represents a NewForge event raised by the Auction contract. +type AuctionNewForge struct { Forger common.Address SlotToForge *big.Int Raw types.Log // Blockchain specific contextual infos @@ -2484,7 +2484,7 @@ type HermezAuctionProtocolNewForge struct { // FilterNewForge is a free log retrieval operation binding the contract event 0x7cae662d4cfa9d9c5575c65f0cc41a858c51ca14ebcbd02a802a62376c3ad238. // // Solidity: event NewForge(address indexed forger, uint128 indexed slotToForge) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewForge(opts *bind.FilterOpts, forger []common.Address, slotToForge []*big.Int) (*HermezAuctionProtocolNewForgeIterator, error) { +func (_Auction *AuctionFilterer) FilterNewForge(opts *bind.FilterOpts, forger []common.Address, slotToForge []*big.Int) (*AuctionNewForgeIterator, error) { var forgerRule []interface{} for _, forgerItem := range forger { @@ -2495,17 +2495,17 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewForge(opts slotToForgeRule = append(slotToForgeRule, slotToForgeItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewForge", forgerRule, slotToForgeRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewForge", forgerRule, slotToForgeRule) if err != nil { return nil, err } - return &HermezAuctionProtocolNewForgeIterator{contract: _HermezAuctionProtocol.contract, event: "NewForge", logs: logs, sub: sub}, nil + return &AuctionNewForgeIterator{contract: _Auction.contract, event: "NewForge", logs: logs, sub: sub}, nil } // WatchNewForge is a free log subscription operation binding the contract event 0x7cae662d4cfa9d9c5575c65f0cc41a858c51ca14ebcbd02a802a62376c3ad238. // // Solidity: event NewForge(address indexed forger, uint128 indexed slotToForge) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForge(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewForge, forger []common.Address, slotToForge []*big.Int) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewForge(opts *bind.WatchOpts, sink chan<- *AuctionNewForge, forger []common.Address, slotToForge []*big.Int) (event.Subscription, error) { var forgerRule []interface{} for _, forgerItem := range forger { @@ -2516,7 +2516,7 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForge(opts slotToForgeRule = append(slotToForgeRule, slotToForgeItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewForge", forgerRule, slotToForgeRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewForge", forgerRule, slotToForgeRule) if err != nil { return nil, err } @@ -2526,8 +2526,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForge(opts select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewForge) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewForge", log); err != nil { + event := new(AuctionNewForge) + if err := _Auction.contract.UnpackLog(event, "NewForge", log); err != nil { return err } event.Raw = log @@ -2551,18 +2551,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForge(opts // ParseNewForge is a log parse operation binding the contract event 0x7cae662d4cfa9d9c5575c65f0cc41a858c51ca14ebcbd02a802a62376c3ad238. // // Solidity: event NewForge(address indexed forger, uint128 indexed slotToForge) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewForge(log types.Log) (*HermezAuctionProtocolNewForge, error) { - event := new(HermezAuctionProtocolNewForge) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewForge", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewForge(log types.Log) (*AuctionNewForge, error) { + event := new(AuctionNewForge) + if err := _Auction.contract.UnpackLog(event, "NewForge", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewForgeAllocatedIterator is returned from FilterNewForgeAllocated and is used to iterate over the raw logs and unpacked data for NewForgeAllocated events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewForgeAllocatedIterator struct { - Event *HermezAuctionProtocolNewForgeAllocated // Event containing the contract specifics and raw log +// AuctionNewForgeAllocatedIterator is returned from FilterNewForgeAllocated and is used to iterate over the raw logs and unpacked data for NewForgeAllocated events raised by the Auction contract. +type AuctionNewForgeAllocatedIterator struct { + Event *AuctionNewForgeAllocated // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2576,7 +2576,7 @@ type HermezAuctionProtocolNewForgeAllocatedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Next() bool { +func (it *AuctionNewForgeAllocatedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2585,7 +2585,7 @@ func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewForgeAllocated) + it.Event = new(AuctionNewForgeAllocated) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2600,7 +2600,7 @@ func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewForgeAllocated) + it.Event = new(AuctionNewForgeAllocated) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2616,19 +2616,19 @@ func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Error() error { +func (it *AuctionNewForgeAllocatedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewForgeAllocatedIterator) Close() error { +func (it *AuctionNewForgeAllocatedIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewForgeAllocated represents a NewForgeAllocated event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewForgeAllocated struct { +// AuctionNewForgeAllocated represents a NewForgeAllocated event raised by the Auction contract. +type AuctionNewForgeAllocated struct { Bidder common.Address Forger common.Address SlotToForge *big.Int @@ -2641,7 +2641,7 @@ type HermezAuctionProtocolNewForgeAllocated struct { // FilterNewForgeAllocated is a free log retrieval operation binding the contract event 0xd64ebb43f4c2b91022b97389834432f1027ef55586129ba05a3a3065b2304f05. // // Solidity: event NewForgeAllocated(address indexed bidder, address indexed forger, uint128 indexed slotToForge, uint128 burnAmount, uint128 donationAmount, uint128 governanceAmount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewForgeAllocated(opts *bind.FilterOpts, bidder []common.Address, forger []common.Address, slotToForge []*big.Int) (*HermezAuctionProtocolNewForgeAllocatedIterator, error) { +func (_Auction *AuctionFilterer) FilterNewForgeAllocated(opts *bind.FilterOpts, bidder []common.Address, forger []common.Address, slotToForge []*big.Int) (*AuctionNewForgeAllocatedIterator, error) { var bidderRule []interface{} for _, bidderItem := range bidder { @@ -2656,17 +2656,17 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewForgeAlloc slotToForgeRule = append(slotToForgeRule, slotToForgeItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewForgeAllocated", bidderRule, forgerRule, slotToForgeRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewForgeAllocated", bidderRule, forgerRule, slotToForgeRule) if err != nil { return nil, err } - return &HermezAuctionProtocolNewForgeAllocatedIterator{contract: _HermezAuctionProtocol.contract, event: "NewForgeAllocated", logs: logs, sub: sub}, nil + return &AuctionNewForgeAllocatedIterator{contract: _Auction.contract, event: "NewForgeAllocated", logs: logs, sub: sub}, nil } // WatchNewForgeAllocated is a free log subscription operation binding the contract event 0xd64ebb43f4c2b91022b97389834432f1027ef55586129ba05a3a3065b2304f05. // // Solidity: event NewForgeAllocated(address indexed bidder, address indexed forger, uint128 indexed slotToForge, uint128 burnAmount, uint128 donationAmount, uint128 governanceAmount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForgeAllocated(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewForgeAllocated, bidder []common.Address, forger []common.Address, slotToForge []*big.Int) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewForgeAllocated(opts *bind.WatchOpts, sink chan<- *AuctionNewForgeAllocated, bidder []common.Address, forger []common.Address, slotToForge []*big.Int) (event.Subscription, error) { var bidderRule []interface{} for _, bidderItem := range bidder { @@ -2681,7 +2681,7 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForgeAlloca slotToForgeRule = append(slotToForgeRule, slotToForgeItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewForgeAllocated", bidderRule, forgerRule, slotToForgeRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewForgeAllocated", bidderRule, forgerRule, slotToForgeRule) if err != nil { return nil, err } @@ -2691,8 +2691,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForgeAlloca select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewForgeAllocated) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewForgeAllocated", log); err != nil { + event := new(AuctionNewForgeAllocated) + if err := _Auction.contract.UnpackLog(event, "NewForgeAllocated", log); err != nil { return err } event.Raw = log @@ -2716,18 +2716,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewForgeAlloca // ParseNewForgeAllocated is a log parse operation binding the contract event 0xd64ebb43f4c2b91022b97389834432f1027ef55586129ba05a3a3065b2304f05. // // Solidity: event NewForgeAllocated(address indexed bidder, address indexed forger, uint128 indexed slotToForge, uint128 burnAmount, uint128 donationAmount, uint128 governanceAmount) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewForgeAllocated(log types.Log) (*HermezAuctionProtocolNewForgeAllocated, error) { - event := new(HermezAuctionProtocolNewForgeAllocated) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewForgeAllocated", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewForgeAllocated(log types.Log) (*AuctionNewForgeAllocated, error) { + event := new(AuctionNewForgeAllocated) + if err := _Auction.contract.UnpackLog(event, "NewForgeAllocated", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewOpenAuctionSlotsIterator is returned from FilterNewOpenAuctionSlots and is used to iterate over the raw logs and unpacked data for NewOpenAuctionSlots events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewOpenAuctionSlotsIterator struct { - Event *HermezAuctionProtocolNewOpenAuctionSlots // Event containing the contract specifics and raw log +// AuctionNewOpenAuctionSlotsIterator is returned from FilterNewOpenAuctionSlots and is used to iterate over the raw logs and unpacked data for NewOpenAuctionSlots events raised by the Auction contract. +type AuctionNewOpenAuctionSlotsIterator struct { + Event *AuctionNewOpenAuctionSlots // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2741,7 +2741,7 @@ type HermezAuctionProtocolNewOpenAuctionSlotsIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Next() bool { +func (it *AuctionNewOpenAuctionSlotsIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2750,7 +2750,7 @@ func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewOpenAuctionSlots) + it.Event = new(AuctionNewOpenAuctionSlots) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2765,7 +2765,7 @@ func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewOpenAuctionSlots) + it.Event = new(AuctionNewOpenAuctionSlots) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2781,19 +2781,19 @@ func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Error() error { +func (it *AuctionNewOpenAuctionSlotsIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewOpenAuctionSlotsIterator) Close() error { +func (it *AuctionNewOpenAuctionSlotsIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewOpenAuctionSlots represents a NewOpenAuctionSlots event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewOpenAuctionSlots struct { +// AuctionNewOpenAuctionSlots represents a NewOpenAuctionSlots event raised by the Auction contract. +type AuctionNewOpenAuctionSlots struct { NewOpenAuctionSlots uint16 Raw types.Log // Blockchain specific contextual infos } @@ -2801,21 +2801,21 @@ type HermezAuctionProtocolNewOpenAuctionSlots struct { // FilterNewOpenAuctionSlots is a free log retrieval operation binding the contract event 0x3da0492dea7298351bc14d1c0699905fd0657c33487449751af50fc0c8b593f1. // // Solidity: event NewOpenAuctionSlots(uint16 newOpenAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewOpenAuctionSlots(opts *bind.FilterOpts) (*HermezAuctionProtocolNewOpenAuctionSlotsIterator, error) { +func (_Auction *AuctionFilterer) FilterNewOpenAuctionSlots(opts *bind.FilterOpts) (*AuctionNewOpenAuctionSlotsIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewOpenAuctionSlots") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewOpenAuctionSlots") if err != nil { return nil, err } - return &HermezAuctionProtocolNewOpenAuctionSlotsIterator{contract: _HermezAuctionProtocol.contract, event: "NewOpenAuctionSlots", logs: logs, sub: sub}, nil + return &AuctionNewOpenAuctionSlotsIterator{contract: _Auction.contract, event: "NewOpenAuctionSlots", logs: logs, sub: sub}, nil } // WatchNewOpenAuctionSlots is a free log subscription operation binding the contract event 0x3da0492dea7298351bc14d1c0699905fd0657c33487449751af50fc0c8b593f1. // // Solidity: event NewOpenAuctionSlots(uint16 newOpenAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOpenAuctionSlots(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewOpenAuctionSlots) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewOpenAuctionSlots(opts *bind.WatchOpts, sink chan<- *AuctionNewOpenAuctionSlots) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewOpenAuctionSlots") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewOpenAuctionSlots") if err != nil { return nil, err } @@ -2825,8 +2825,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOpenAuction select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewOpenAuctionSlots) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewOpenAuctionSlots", log); err != nil { + event := new(AuctionNewOpenAuctionSlots) + if err := _Auction.contract.UnpackLog(event, "NewOpenAuctionSlots", log); err != nil { return err } event.Raw = log @@ -2850,18 +2850,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOpenAuction // ParseNewOpenAuctionSlots is a log parse operation binding the contract event 0x3da0492dea7298351bc14d1c0699905fd0657c33487449751af50fc0c8b593f1. // // Solidity: event NewOpenAuctionSlots(uint16 newOpenAuctionSlots) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewOpenAuctionSlots(log types.Log) (*HermezAuctionProtocolNewOpenAuctionSlots, error) { - event := new(HermezAuctionProtocolNewOpenAuctionSlots) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewOpenAuctionSlots", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewOpenAuctionSlots(log types.Log) (*AuctionNewOpenAuctionSlots, error) { + event := new(AuctionNewOpenAuctionSlots) + if err := _Auction.contract.UnpackLog(event, "NewOpenAuctionSlots", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewOutbiddingIterator is returned from FilterNewOutbidding and is used to iterate over the raw logs and unpacked data for NewOutbidding events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewOutbiddingIterator struct { - Event *HermezAuctionProtocolNewOutbidding // Event containing the contract specifics and raw log +// AuctionNewOutbiddingIterator is returned from FilterNewOutbidding and is used to iterate over the raw logs and unpacked data for NewOutbidding events raised by the Auction contract. +type AuctionNewOutbiddingIterator struct { + Event *AuctionNewOutbidding // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2875,7 +2875,7 @@ type HermezAuctionProtocolNewOutbiddingIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewOutbiddingIterator) Next() bool { +func (it *AuctionNewOutbiddingIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2884,7 +2884,7 @@ func (it *HermezAuctionProtocolNewOutbiddingIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewOutbidding) + it.Event = new(AuctionNewOutbidding) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2899,7 +2899,7 @@ func (it *HermezAuctionProtocolNewOutbiddingIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewOutbidding) + it.Event = new(AuctionNewOutbidding) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2915,19 +2915,19 @@ func (it *HermezAuctionProtocolNewOutbiddingIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewOutbiddingIterator) Error() error { +func (it *AuctionNewOutbiddingIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewOutbiddingIterator) Close() error { +func (it *AuctionNewOutbiddingIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewOutbidding represents a NewOutbidding event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewOutbidding struct { +// AuctionNewOutbidding represents a NewOutbidding event raised by the Auction contract. +type AuctionNewOutbidding struct { NewOutbidding uint16 Raw types.Log // Blockchain specific contextual infos } @@ -2935,21 +2935,21 @@ type HermezAuctionProtocolNewOutbidding struct { // FilterNewOutbidding is a free log retrieval operation binding the contract event 0xd3748b8c326e93d12af934fbf87471e315a89bc3f7b8222343acf0210edf248e. // // Solidity: event NewOutbidding(uint16 newOutbidding) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewOutbidding(opts *bind.FilterOpts) (*HermezAuctionProtocolNewOutbiddingIterator, error) { +func (_Auction *AuctionFilterer) FilterNewOutbidding(opts *bind.FilterOpts) (*AuctionNewOutbiddingIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewOutbidding") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewOutbidding") if err != nil { return nil, err } - return &HermezAuctionProtocolNewOutbiddingIterator{contract: _HermezAuctionProtocol.contract, event: "NewOutbidding", logs: logs, sub: sub}, nil + return &AuctionNewOutbiddingIterator{contract: _Auction.contract, event: "NewOutbidding", logs: logs, sub: sub}, nil } // WatchNewOutbidding is a free log subscription operation binding the contract event 0xd3748b8c326e93d12af934fbf87471e315a89bc3f7b8222343acf0210edf248e. // // Solidity: event NewOutbidding(uint16 newOutbidding) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOutbidding(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewOutbidding) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewOutbidding(opts *bind.WatchOpts, sink chan<- *AuctionNewOutbidding) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewOutbidding") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewOutbidding") if err != nil { return nil, err } @@ -2959,8 +2959,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOutbidding( select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewOutbidding) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewOutbidding", log); err != nil { + event := new(AuctionNewOutbidding) + if err := _Auction.contract.UnpackLog(event, "NewOutbidding", log); err != nil { return err } event.Raw = log @@ -2984,18 +2984,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewOutbidding( // ParseNewOutbidding is a log parse operation binding the contract event 0xd3748b8c326e93d12af934fbf87471e315a89bc3f7b8222343acf0210edf248e. // // Solidity: event NewOutbidding(uint16 newOutbidding) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewOutbidding(log types.Log) (*HermezAuctionProtocolNewOutbidding, error) { - event := new(HermezAuctionProtocolNewOutbidding) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewOutbidding", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewOutbidding(log types.Log) (*AuctionNewOutbidding, error) { + event := new(AuctionNewOutbidding) + if err := _Auction.contract.UnpackLog(event, "NewOutbidding", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolNewSlotDeadlineIterator is returned from FilterNewSlotDeadline and is used to iterate over the raw logs and unpacked data for NewSlotDeadline events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewSlotDeadlineIterator struct { - Event *HermezAuctionProtocolNewSlotDeadline // Event containing the contract specifics and raw log +// AuctionNewSlotDeadlineIterator is returned from FilterNewSlotDeadline and is used to iterate over the raw logs and unpacked data for NewSlotDeadline events raised by the Auction contract. +type AuctionNewSlotDeadlineIterator struct { + Event *AuctionNewSlotDeadline // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -3009,7 +3009,7 @@ type HermezAuctionProtocolNewSlotDeadlineIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Next() bool { +func (it *AuctionNewSlotDeadlineIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -3018,7 +3018,7 @@ func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewSlotDeadline) + it.Event = new(AuctionNewSlotDeadline) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3033,7 +3033,7 @@ func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolNewSlotDeadline) + it.Event = new(AuctionNewSlotDeadline) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3049,19 +3049,19 @@ func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Error() error { +func (it *AuctionNewSlotDeadlineIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolNewSlotDeadlineIterator) Close() error { +func (it *AuctionNewSlotDeadlineIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolNewSlotDeadline represents a NewSlotDeadline event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolNewSlotDeadline struct { +// AuctionNewSlotDeadline represents a NewSlotDeadline event raised by the Auction contract. +type AuctionNewSlotDeadline struct { NewSlotDeadline uint8 Raw types.Log // Blockchain specific contextual infos } @@ -3069,21 +3069,21 @@ type HermezAuctionProtocolNewSlotDeadline struct { // FilterNewSlotDeadline is a free log retrieval operation binding the contract event 0x4a0d90b611c15e02dbf23b10f35b936cf2c77665f8c77822d3eca131f9d986d3. // // Solidity: event NewSlotDeadline(uint8 newSlotDeadline) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterNewSlotDeadline(opts *bind.FilterOpts) (*HermezAuctionProtocolNewSlotDeadlineIterator, error) { +func (_Auction *AuctionFilterer) FilterNewSlotDeadline(opts *bind.FilterOpts) (*AuctionNewSlotDeadlineIterator, error) { - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "NewSlotDeadline") + logs, sub, err := _Auction.contract.FilterLogs(opts, "NewSlotDeadline") if err != nil { return nil, err } - return &HermezAuctionProtocolNewSlotDeadlineIterator{contract: _HermezAuctionProtocol.contract, event: "NewSlotDeadline", logs: logs, sub: sub}, nil + return &AuctionNewSlotDeadlineIterator{contract: _Auction.contract, event: "NewSlotDeadline", logs: logs, sub: sub}, nil } // WatchNewSlotDeadline is a free log subscription operation binding the contract event 0x4a0d90b611c15e02dbf23b10f35b936cf2c77665f8c77822d3eca131f9d986d3. // // Solidity: event NewSlotDeadline(uint8 newSlotDeadline) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewSlotDeadline(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolNewSlotDeadline) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchNewSlotDeadline(opts *bind.WatchOpts, sink chan<- *AuctionNewSlotDeadline) (event.Subscription, error) { - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "NewSlotDeadline") + logs, sub, err := _Auction.contract.WatchLogs(opts, "NewSlotDeadline") if err != nil { return nil, err } @@ -3093,8 +3093,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewSlotDeadlin select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolNewSlotDeadline) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewSlotDeadline", log); err != nil { + event := new(AuctionNewSlotDeadline) + if err := _Auction.contract.UnpackLog(event, "NewSlotDeadline", log); err != nil { return err } event.Raw = log @@ -3118,18 +3118,18 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchNewSlotDeadlin // ParseNewSlotDeadline is a log parse operation binding the contract event 0x4a0d90b611c15e02dbf23b10f35b936cf2c77665f8c77822d3eca131f9d986d3. // // Solidity: event NewSlotDeadline(uint8 newSlotDeadline) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseNewSlotDeadline(log types.Log) (*HermezAuctionProtocolNewSlotDeadline, error) { - event := new(HermezAuctionProtocolNewSlotDeadline) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "NewSlotDeadline", log); err != nil { +func (_Auction *AuctionFilterer) ParseNewSlotDeadline(log types.Log) (*AuctionNewSlotDeadline, error) { + event := new(AuctionNewSlotDeadline) + if err := _Auction.contract.UnpackLog(event, "NewSlotDeadline", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HermezAuctionProtocolSetCoordinatorIterator is returned from FilterSetCoordinator and is used to iterate over the raw logs and unpacked data for SetCoordinator events raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolSetCoordinatorIterator struct { - Event *HermezAuctionProtocolSetCoordinator // Event containing the contract specifics and raw log +// AuctionSetCoordinatorIterator is returned from FilterSetCoordinator and is used to iterate over the raw logs and unpacked data for SetCoordinator events raised by the Auction contract. +type AuctionSetCoordinatorIterator struct { + Event *AuctionSetCoordinator // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -3143,7 +3143,7 @@ type HermezAuctionProtocolSetCoordinatorIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HermezAuctionProtocolSetCoordinatorIterator) Next() bool { +func (it *AuctionSetCoordinatorIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -3152,7 +3152,7 @@ func (it *HermezAuctionProtocolSetCoordinatorIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolSetCoordinator) + it.Event = new(AuctionSetCoordinator) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3167,7 +3167,7 @@ func (it *HermezAuctionProtocolSetCoordinatorIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HermezAuctionProtocolSetCoordinator) + it.Event = new(AuctionSetCoordinator) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3183,19 +3183,19 @@ func (it *HermezAuctionProtocolSetCoordinatorIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HermezAuctionProtocolSetCoordinatorIterator) Error() error { +func (it *AuctionSetCoordinatorIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HermezAuctionProtocolSetCoordinatorIterator) Close() error { +func (it *AuctionSetCoordinatorIterator) Close() error { it.sub.Unsubscribe() return nil } -// HermezAuctionProtocolSetCoordinator represents a SetCoordinator event raised by the HermezAuctionProtocol contract. -type HermezAuctionProtocolSetCoordinator struct { +// AuctionSetCoordinator represents a SetCoordinator event raised by the Auction contract. +type AuctionSetCoordinator struct { Bidder common.Address Forger common.Address CoordinatorURL string @@ -3205,7 +3205,7 @@ type HermezAuctionProtocolSetCoordinator struct { // FilterSetCoordinator is a free log retrieval operation binding the contract event 0x5246b2ac9ee77efe2e64af6df00055d97e2d6e1b277f5a8d17ba5bca1a573da0. // // Solidity: event SetCoordinator(address indexed bidder, address indexed forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterSetCoordinator(opts *bind.FilterOpts, bidder []common.Address, forger []common.Address) (*HermezAuctionProtocolSetCoordinatorIterator, error) { +func (_Auction *AuctionFilterer) FilterSetCoordinator(opts *bind.FilterOpts, bidder []common.Address, forger []common.Address) (*AuctionSetCoordinatorIterator, error) { var bidderRule []interface{} for _, bidderItem := range bidder { @@ -3216,17 +3216,17 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) FilterSetCoordinato forgerRule = append(forgerRule, forgerItem) } - logs, sub, err := _HermezAuctionProtocol.contract.FilterLogs(opts, "SetCoordinator", bidderRule, forgerRule) + logs, sub, err := _Auction.contract.FilterLogs(opts, "SetCoordinator", bidderRule, forgerRule) if err != nil { return nil, err } - return &HermezAuctionProtocolSetCoordinatorIterator{contract: _HermezAuctionProtocol.contract, event: "SetCoordinator", logs: logs, sub: sub}, nil + return &AuctionSetCoordinatorIterator{contract: _Auction.contract, event: "SetCoordinator", logs: logs, sub: sub}, nil } // WatchSetCoordinator is a free log subscription operation binding the contract event 0x5246b2ac9ee77efe2e64af6df00055d97e2d6e1b277f5a8d17ba5bca1a573da0. // // Solidity: event SetCoordinator(address indexed bidder, address indexed forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchSetCoordinator(opts *bind.WatchOpts, sink chan<- *HermezAuctionProtocolSetCoordinator, bidder []common.Address, forger []common.Address) (event.Subscription, error) { +func (_Auction *AuctionFilterer) WatchSetCoordinator(opts *bind.WatchOpts, sink chan<- *AuctionSetCoordinator, bidder []common.Address, forger []common.Address) (event.Subscription, error) { var bidderRule []interface{} for _, bidderItem := range bidder { @@ -3237,7 +3237,7 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchSetCoordinator forgerRule = append(forgerRule, forgerItem) } - logs, sub, err := _HermezAuctionProtocol.contract.WatchLogs(opts, "SetCoordinator", bidderRule, forgerRule) + logs, sub, err := _Auction.contract.WatchLogs(opts, "SetCoordinator", bidderRule, forgerRule) if err != nil { return nil, err } @@ -3247,8 +3247,8 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchSetCoordinator select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HermezAuctionProtocolSetCoordinator) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "SetCoordinator", log); err != nil { + event := new(AuctionSetCoordinator) + if err := _Auction.contract.UnpackLog(event, "SetCoordinator", log); err != nil { return err } event.Raw = log @@ -3272,9 +3272,9 @@ func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) WatchSetCoordinator // ParseSetCoordinator is a log parse operation binding the contract event 0x5246b2ac9ee77efe2e64af6df00055d97e2d6e1b277f5a8d17ba5bca1a573da0. // // Solidity: event SetCoordinator(address indexed bidder, address indexed forger, string coordinatorURL) -func (_HermezAuctionProtocol *HermezAuctionProtocolFilterer) ParseSetCoordinator(log types.Log) (*HermezAuctionProtocolSetCoordinator, error) { - event := new(HermezAuctionProtocolSetCoordinator) - if err := _HermezAuctionProtocol.contract.UnpackLog(event, "SetCoordinator", log); err != nil { +func (_Auction *AuctionFilterer) ParseSetCoordinator(log types.Log) (*AuctionSetCoordinator, error) { + event := new(AuctionSetCoordinator) + if err := _Auction.contract.UnpackLog(event, "SetCoordinator", log); err != nil { return nil, err } event.Raw = log diff --git a/eth/contracts/hermez/Hermez.go b/eth/contracts/hermez/hermez.go similarity index 99% rename from eth/contracts/hermez/Hermez.go rename to eth/contracts/hermez/hermez.go index f6d4dd0c0..ecf6c97d6 100644 --- a/eth/contracts/hermez/Hermez.go +++ b/eth/contracts/hermez/hermez.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package Hermez +package hermez import ( "math/big" diff --git a/eth/contracts/tokenHEZ/HEZ.go b/eth/contracts/tokenhez/tokenhez.go similarity index 50% rename from eth/contracts/tokenHEZ/HEZ.go rename to eth/contracts/tokenhez/tokenhez.go index e84bbafeb..00fae501d 100644 --- a/eth/contracts/tokenHEZ/HEZ.go +++ b/eth/contracts/tokenhez/tokenhez.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package HEZ +package tokenhez import ( "math/big" @@ -26,107 +26,107 @@ var ( _ = event.NewSubscription ) -// HEZABI is the input ABI used to generate the binding from. -const HEZABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialHolder\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nonce\",\"type\":\"bytes32\"}],\"name\":\"AuthorizationUsed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"EIP712DOMAIN_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NAME_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_WITH_AUTHORIZATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"authorizationState\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"defaultMintAmount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"validAfter\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"validBefore\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"nonce\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"transferWithAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]" +// TokenhezABI is the input ABI used to generate the binding from. +const TokenhezABI = "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"initialHolder\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"authorizer\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"nonce\",\"type\":\"bytes32\"}],\"name\":\"AuthorizationUsed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"EIP712DOMAIN_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"NAME_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"PERMIT_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"TRANSFER_WITH_AUTHORIZATION_TYPEHASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"VERSION_HASH\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"authorizationState\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getChainId\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"chainId\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initialBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"validAfter\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"validBefore\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"nonce\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"transferWithAuthorization\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" -// HEZ is an auto generated Go binding around an Ethereum contract. -type HEZ struct { - HEZCaller // Read-only binding to the contract - HEZTransactor // Write-only binding to the contract - HEZFilterer // Log filterer for contract events +// Tokenhez is an auto generated Go binding around an Ethereum contract. +type Tokenhez struct { + TokenhezCaller // Read-only binding to the contract + TokenhezTransactor // Write-only binding to the contract + TokenhezFilterer // Log filterer for contract events } -// HEZCaller is an auto generated read-only Go binding around an Ethereum contract. -type HEZCaller struct { +// TokenhezCaller is an auto generated read-only Go binding around an Ethereum contract. +type TokenhezCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HEZTransactor is an auto generated write-only Go binding around an Ethereum contract. -type HEZTransactor struct { +// TokenhezTransactor is an auto generated write-only Go binding around an Ethereum contract. +type TokenhezTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HEZFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type HEZFilterer struct { +// TokenhezFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type TokenhezFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// HEZSession is an auto generated Go binding around an Ethereum contract, +// TokenhezSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. -type HEZSession struct { - Contract *HEZ // Generic contract binding to set the session for +type TokenhezSession struct { + Contract *Tokenhez // Generic contract binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// HEZCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// TokenhezCallerSession is an auto generated read-only Go binding around an Ethereum contract, // with pre-set call options. -type HEZCallerSession struct { - Contract *HEZCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session +type TokenhezCallerSession struct { + Contract *TokenhezCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session } -// HEZTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// TokenhezTransactorSession is an auto generated write-only Go binding around an Ethereum contract, // with pre-set transact options. -type HEZTransactorSession struct { - Contract *HEZTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +type TokenhezTransactorSession struct { + Contract *TokenhezTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// HEZRaw is an auto generated low-level Go binding around an Ethereum contract. -type HEZRaw struct { - Contract *HEZ // Generic contract binding to access the raw methods on +// TokenhezRaw is an auto generated low-level Go binding around an Ethereum contract. +type TokenhezRaw struct { + Contract *Tokenhez // Generic contract binding to access the raw methods on } -// HEZCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type HEZCallerRaw struct { - Contract *HEZCaller // Generic read-only contract binding to access the raw methods on +// TokenhezCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type TokenhezCallerRaw struct { + Contract *TokenhezCaller // Generic read-only contract binding to access the raw methods on } -// HEZTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type HEZTransactorRaw struct { - Contract *HEZTransactor // Generic write-only contract binding to access the raw methods on +// TokenhezTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type TokenhezTransactorRaw struct { + Contract *TokenhezTransactor // Generic write-only contract binding to access the raw methods on } -// NewHEZ creates a new instance of HEZ, bound to a specific deployed contract. -func NewHEZ(address common.Address, backend bind.ContractBackend) (*HEZ, error) { - contract, err := bindHEZ(address, backend, backend, backend) +// NewTokenhez creates a new instance of Tokenhez, bound to a specific deployed contract. +func NewTokenhez(address common.Address, backend bind.ContractBackend) (*Tokenhez, error) { + contract, err := bindTokenhez(address, backend, backend, backend) if err != nil { return nil, err } - return &HEZ{HEZCaller: HEZCaller{contract: contract}, HEZTransactor: HEZTransactor{contract: contract}, HEZFilterer: HEZFilterer{contract: contract}}, nil + return &Tokenhez{TokenhezCaller: TokenhezCaller{contract: contract}, TokenhezTransactor: TokenhezTransactor{contract: contract}, TokenhezFilterer: TokenhezFilterer{contract: contract}}, nil } -// NewHEZCaller creates a new read-only instance of HEZ, bound to a specific deployed contract. -func NewHEZCaller(address common.Address, caller bind.ContractCaller) (*HEZCaller, error) { - contract, err := bindHEZ(address, caller, nil, nil) +// NewTokenhezCaller creates a new read-only instance of Tokenhez, bound to a specific deployed contract. +func NewTokenhezCaller(address common.Address, caller bind.ContractCaller) (*TokenhezCaller, error) { + contract, err := bindTokenhez(address, caller, nil, nil) if err != nil { return nil, err } - return &HEZCaller{contract: contract}, nil + return &TokenhezCaller{contract: contract}, nil } -// NewHEZTransactor creates a new write-only instance of HEZ, bound to a specific deployed contract. -func NewHEZTransactor(address common.Address, transactor bind.ContractTransactor) (*HEZTransactor, error) { - contract, err := bindHEZ(address, nil, transactor, nil) +// NewTokenhezTransactor creates a new write-only instance of Tokenhez, bound to a specific deployed contract. +func NewTokenhezTransactor(address common.Address, transactor bind.ContractTransactor) (*TokenhezTransactor, error) { + contract, err := bindTokenhez(address, nil, transactor, nil) if err != nil { return nil, err } - return &HEZTransactor{contract: contract}, nil + return &TokenhezTransactor{contract: contract}, nil } -// NewHEZFilterer creates a new log filterer instance of HEZ, bound to a specific deployed contract. -func NewHEZFilterer(address common.Address, filterer bind.ContractFilterer) (*HEZFilterer, error) { - contract, err := bindHEZ(address, nil, nil, filterer) +// NewTokenhezFilterer creates a new log filterer instance of Tokenhez, bound to a specific deployed contract. +func NewTokenhezFilterer(address common.Address, filterer bind.ContractFilterer) (*TokenhezFilterer, error) { + contract, err := bindTokenhez(address, nil, nil, filterer) if err != nil { return nil, err } - return &HEZFilterer{contract: contract}, nil + return &TokenhezFilterer{contract: contract}, nil } -// bindHEZ binds a generic wrapper to an already deployed contract. -func bindHEZ(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(HEZABI)) +// bindTokenhez binds a generic wrapper to an already deployed contract. +func bindTokenhez(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(TokenhezABI)) if err != nil { return nil, err } @@ -137,46 +137,46 @@ func bindHEZ(address common.Address, caller bind.ContractCaller, transactor bind // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_HEZ *HEZRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HEZ.Contract.HEZCaller.contract.Call(opts, result, method, params...) +func (_Tokenhez *TokenhezRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Tokenhez.Contract.TokenhezCaller.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_HEZ *HEZRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HEZ.Contract.HEZTransactor.contract.Transfer(opts) +func (_Tokenhez *TokenhezRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Tokenhez.Contract.TokenhezTransactor.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_HEZ *HEZRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HEZ.Contract.HEZTransactor.contract.Transact(opts, method, params...) +func (_Tokenhez *TokenhezRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Tokenhez.Contract.TokenhezTransactor.contract.Transact(opts, method, params...) } // Call invokes the (constant) contract method with params as input values and // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_HEZ *HEZCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HEZ.Contract.contract.Call(opts, result, method, params...) +func (_Tokenhez *TokenhezCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Tokenhez.Contract.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_HEZ *HEZTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HEZ.Contract.contract.Transfer(opts) +func (_Tokenhez *TokenhezTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Tokenhez.Contract.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_HEZ *HEZTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HEZ.Contract.contract.Transact(opts, method, params...) +func (_Tokenhez *TokenhezTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Tokenhez.Contract.contract.Transact(opts, method, params...) } // EIP712DOMAINHASH is a free data retrieval call binding the contract method 0xc473af33. // // Solidity: function EIP712DOMAIN_HASH() view returns(bytes32) -func (_HEZ *HEZCaller) EIP712DOMAINHASH(opts *bind.CallOpts) ([32]byte, error) { +func (_Tokenhez *TokenhezCaller) EIP712DOMAINHASH(opts *bind.CallOpts) ([32]byte, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "EIP712DOMAIN_HASH") + err := _Tokenhez.contract.Call(opts, &out, "EIP712DOMAIN_HASH") if err != nil { return *new([32]byte), err @@ -191,23 +191,23 @@ func (_HEZ *HEZCaller) EIP712DOMAINHASH(opts *bind.CallOpts) ([32]byte, error) { // EIP712DOMAINHASH is a free data retrieval call binding the contract method 0xc473af33. // // Solidity: function EIP712DOMAIN_HASH() view returns(bytes32) -func (_HEZ *HEZSession) EIP712DOMAINHASH() ([32]byte, error) { - return _HEZ.Contract.EIP712DOMAINHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) EIP712DOMAINHASH() ([32]byte, error) { + return _Tokenhez.Contract.EIP712DOMAINHASH(&_Tokenhez.CallOpts) } // EIP712DOMAINHASH is a free data retrieval call binding the contract method 0xc473af33. // // Solidity: function EIP712DOMAIN_HASH() view returns(bytes32) -func (_HEZ *HEZCallerSession) EIP712DOMAINHASH() ([32]byte, error) { - return _HEZ.Contract.EIP712DOMAINHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) EIP712DOMAINHASH() ([32]byte, error) { + return _Tokenhez.Contract.EIP712DOMAINHASH(&_Tokenhez.CallOpts) } // NAMEHASH is a free data retrieval call binding the contract method 0x04622c2e. // // Solidity: function NAME_HASH() view returns(bytes32) -func (_HEZ *HEZCaller) NAMEHASH(opts *bind.CallOpts) ([32]byte, error) { +func (_Tokenhez *TokenhezCaller) NAMEHASH(opts *bind.CallOpts) ([32]byte, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "NAME_HASH") + err := _Tokenhez.contract.Call(opts, &out, "NAME_HASH") if err != nil { return *new([32]byte), err @@ -222,23 +222,23 @@ func (_HEZ *HEZCaller) NAMEHASH(opts *bind.CallOpts) ([32]byte, error) { // NAMEHASH is a free data retrieval call binding the contract method 0x04622c2e. // // Solidity: function NAME_HASH() view returns(bytes32) -func (_HEZ *HEZSession) NAMEHASH() ([32]byte, error) { - return _HEZ.Contract.NAMEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) NAMEHASH() ([32]byte, error) { + return _Tokenhez.Contract.NAMEHASH(&_Tokenhez.CallOpts) } // NAMEHASH is a free data retrieval call binding the contract method 0x04622c2e. // // Solidity: function NAME_HASH() view returns(bytes32) -func (_HEZ *HEZCallerSession) NAMEHASH() ([32]byte, error) { - return _HEZ.Contract.NAMEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) NAMEHASH() ([32]byte, error) { + return _Tokenhez.Contract.NAMEHASH(&_Tokenhez.CallOpts) } // PERMITTYPEHASH is a free data retrieval call binding the contract method 0x30adf81f. // // Solidity: function PERMIT_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZCaller) PERMITTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { +func (_Tokenhez *TokenhezCaller) PERMITTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "PERMIT_TYPEHASH") + err := _Tokenhez.contract.Call(opts, &out, "PERMIT_TYPEHASH") if err != nil { return *new([32]byte), err @@ -253,23 +253,23 @@ func (_HEZ *HEZCaller) PERMITTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { // PERMITTYPEHASH is a free data retrieval call binding the contract method 0x30adf81f. // // Solidity: function PERMIT_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZSession) PERMITTYPEHASH() ([32]byte, error) { - return _HEZ.Contract.PERMITTYPEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) PERMITTYPEHASH() ([32]byte, error) { + return _Tokenhez.Contract.PERMITTYPEHASH(&_Tokenhez.CallOpts) } // PERMITTYPEHASH is a free data retrieval call binding the contract method 0x30adf81f. // // Solidity: function PERMIT_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZCallerSession) PERMITTYPEHASH() ([32]byte, error) { - return _HEZ.Contract.PERMITTYPEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) PERMITTYPEHASH() ([32]byte, error) { + return _Tokenhez.Contract.PERMITTYPEHASH(&_Tokenhez.CallOpts) } // TRANSFERWITHAUTHORIZATIONTYPEHASH is a free data retrieval call binding the contract method 0xa0cc6a68. // // Solidity: function TRANSFER_WITH_AUTHORIZATION_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZCaller) TRANSFERWITHAUTHORIZATIONTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { +func (_Tokenhez *TokenhezCaller) TRANSFERWITHAUTHORIZATIONTYPEHASH(opts *bind.CallOpts) ([32]byte, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "TRANSFER_WITH_AUTHORIZATION_TYPEHASH") + err := _Tokenhez.contract.Call(opts, &out, "TRANSFER_WITH_AUTHORIZATION_TYPEHASH") if err != nil { return *new([32]byte), err @@ -284,23 +284,23 @@ func (_HEZ *HEZCaller) TRANSFERWITHAUTHORIZATIONTYPEHASH(opts *bind.CallOpts) ([ // TRANSFERWITHAUTHORIZATIONTYPEHASH is a free data retrieval call binding the contract method 0xa0cc6a68. // // Solidity: function TRANSFER_WITH_AUTHORIZATION_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZSession) TRANSFERWITHAUTHORIZATIONTYPEHASH() ([32]byte, error) { - return _HEZ.Contract.TRANSFERWITHAUTHORIZATIONTYPEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) TRANSFERWITHAUTHORIZATIONTYPEHASH() ([32]byte, error) { + return _Tokenhez.Contract.TRANSFERWITHAUTHORIZATIONTYPEHASH(&_Tokenhez.CallOpts) } // TRANSFERWITHAUTHORIZATIONTYPEHASH is a free data retrieval call binding the contract method 0xa0cc6a68. // // Solidity: function TRANSFER_WITH_AUTHORIZATION_TYPEHASH() view returns(bytes32) -func (_HEZ *HEZCallerSession) TRANSFERWITHAUTHORIZATIONTYPEHASH() ([32]byte, error) { - return _HEZ.Contract.TRANSFERWITHAUTHORIZATIONTYPEHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) TRANSFERWITHAUTHORIZATIONTYPEHASH() ([32]byte, error) { + return _Tokenhez.Contract.TRANSFERWITHAUTHORIZATIONTYPEHASH(&_Tokenhez.CallOpts) } // VERSIONHASH is a free data retrieval call binding the contract method 0x9e4e7318. // // Solidity: function VERSION_HASH() view returns(bytes32) -func (_HEZ *HEZCaller) VERSIONHASH(opts *bind.CallOpts) ([32]byte, error) { +func (_Tokenhez *TokenhezCaller) VERSIONHASH(opts *bind.CallOpts) ([32]byte, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "VERSION_HASH") + err := _Tokenhez.contract.Call(opts, &out, "VERSION_HASH") if err != nil { return *new([32]byte), err @@ -315,23 +315,23 @@ func (_HEZ *HEZCaller) VERSIONHASH(opts *bind.CallOpts) ([32]byte, error) { // VERSIONHASH is a free data retrieval call binding the contract method 0x9e4e7318. // // Solidity: function VERSION_HASH() view returns(bytes32) -func (_HEZ *HEZSession) VERSIONHASH() ([32]byte, error) { - return _HEZ.Contract.VERSIONHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) VERSIONHASH() ([32]byte, error) { + return _Tokenhez.Contract.VERSIONHASH(&_Tokenhez.CallOpts) } // VERSIONHASH is a free data retrieval call binding the contract method 0x9e4e7318. // // Solidity: function VERSION_HASH() view returns(bytes32) -func (_HEZ *HEZCallerSession) VERSIONHASH() ([32]byte, error) { - return _HEZ.Contract.VERSIONHASH(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) VERSIONHASH() ([32]byte, error) { + return _Tokenhez.Contract.VERSIONHASH(&_Tokenhez.CallOpts) } // Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. // // Solidity: function allowance(address , address ) view returns(uint256) -func (_HEZ *HEZCaller) Allowance(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) Allowance(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "allowance", arg0, arg1) + err := _Tokenhez.contract.Call(opts, &out, "allowance", arg0, arg1) if err != nil { return *new(*big.Int), err @@ -346,23 +346,23 @@ func (_HEZ *HEZCaller) Allowance(opts *bind.CallOpts, arg0 common.Address, arg1 // Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. // // Solidity: function allowance(address , address ) view returns(uint256) -func (_HEZ *HEZSession) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HEZ.Contract.Allowance(&_HEZ.CallOpts, arg0, arg1) +func (_Tokenhez *TokenhezSession) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.Allowance(&_Tokenhez.CallOpts, arg0, arg1) } // Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. // // Solidity: function allowance(address , address ) view returns(uint256) -func (_HEZ *HEZCallerSession) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HEZ.Contract.Allowance(&_HEZ.CallOpts, arg0, arg1) +func (_Tokenhez *TokenhezCallerSession) Allowance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.Allowance(&_Tokenhez.CallOpts, arg0, arg1) } // AuthorizationState is a free data retrieval call binding the contract method 0xe94a0102. // // Solidity: function authorizationState(address , bytes32 ) view returns(bool) -func (_HEZ *HEZCaller) AuthorizationState(opts *bind.CallOpts, arg0 common.Address, arg1 [32]byte) (bool, error) { +func (_Tokenhez *TokenhezCaller) AuthorizationState(opts *bind.CallOpts, arg0 common.Address, arg1 [32]byte) (bool, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "authorizationState", arg0, arg1) + err := _Tokenhez.contract.Call(opts, &out, "authorizationState", arg0, arg1) if err != nil { return *new(bool), err @@ -377,23 +377,23 @@ func (_HEZ *HEZCaller) AuthorizationState(opts *bind.CallOpts, arg0 common.Addre // AuthorizationState is a free data retrieval call binding the contract method 0xe94a0102. // // Solidity: function authorizationState(address , bytes32 ) view returns(bool) -func (_HEZ *HEZSession) AuthorizationState(arg0 common.Address, arg1 [32]byte) (bool, error) { - return _HEZ.Contract.AuthorizationState(&_HEZ.CallOpts, arg0, arg1) +func (_Tokenhez *TokenhezSession) AuthorizationState(arg0 common.Address, arg1 [32]byte) (bool, error) { + return _Tokenhez.Contract.AuthorizationState(&_Tokenhez.CallOpts, arg0, arg1) } // AuthorizationState is a free data retrieval call binding the contract method 0xe94a0102. // // Solidity: function authorizationState(address , bytes32 ) view returns(bool) -func (_HEZ *HEZCallerSession) AuthorizationState(arg0 common.Address, arg1 [32]byte) (bool, error) { - return _HEZ.Contract.AuthorizationState(&_HEZ.CallOpts, arg0, arg1) +func (_Tokenhez *TokenhezCallerSession) AuthorizationState(arg0 common.Address, arg1 [32]byte) (bool, error) { + return _Tokenhez.Contract.AuthorizationState(&_Tokenhez.CallOpts, arg0, arg1) } // BalanceOf is a free data retrieval call binding the contract method 0x70a08231. // // Solidity: function balanceOf(address ) view returns(uint256) -func (_HEZ *HEZCaller) BalanceOf(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) BalanceOf(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "balanceOf", arg0) + err := _Tokenhez.contract.Call(opts, &out, "balanceOf", arg0) if err != nil { return *new(*big.Int), err @@ -408,23 +408,23 @@ func (_HEZ *HEZCaller) BalanceOf(opts *bind.CallOpts, arg0 common.Address) (*big // BalanceOf is a free data retrieval call binding the contract method 0x70a08231. // // Solidity: function balanceOf(address ) view returns(uint256) -func (_HEZ *HEZSession) BalanceOf(arg0 common.Address) (*big.Int, error) { - return _HEZ.Contract.BalanceOf(&_HEZ.CallOpts, arg0) +func (_Tokenhez *TokenhezSession) BalanceOf(arg0 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.BalanceOf(&_Tokenhez.CallOpts, arg0) } // BalanceOf is a free data retrieval call binding the contract method 0x70a08231. // // Solidity: function balanceOf(address ) view returns(uint256) -func (_HEZ *HEZCallerSession) BalanceOf(arg0 common.Address) (*big.Int, error) { - return _HEZ.Contract.BalanceOf(&_HEZ.CallOpts, arg0) +func (_Tokenhez *TokenhezCallerSession) BalanceOf(arg0 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.BalanceOf(&_Tokenhez.CallOpts, arg0) } // Decimals is a free data retrieval call binding the contract method 0x313ce567. // // Solidity: function decimals() view returns(uint8) -func (_HEZ *HEZCaller) Decimals(opts *bind.CallOpts) (uint8, error) { +func (_Tokenhez *TokenhezCaller) Decimals(opts *bind.CallOpts) (uint8, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "decimals") + err := _Tokenhez.contract.Call(opts, &out, "decimals") if err != nil { return *new(uint8), err @@ -439,54 +439,23 @@ func (_HEZ *HEZCaller) Decimals(opts *bind.CallOpts) (uint8, error) { // Decimals is a free data retrieval call binding the contract method 0x313ce567. // // Solidity: function decimals() view returns(uint8) -func (_HEZ *HEZSession) Decimals() (uint8, error) { - return _HEZ.Contract.Decimals(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) Decimals() (uint8, error) { + return _Tokenhez.Contract.Decimals(&_Tokenhez.CallOpts) } // Decimals is a free data retrieval call binding the contract method 0x313ce567. // // Solidity: function decimals() view returns(uint8) -func (_HEZ *HEZCallerSession) Decimals() (uint8, error) { - return _HEZ.Contract.Decimals(&_HEZ.CallOpts) -} - -// DefaultMintAmount is a free data retrieval call binding the contract method 0x05b23f2f. -// -// Solidity: function defaultMintAmount() view returns(uint256) -func (_HEZ *HEZCaller) DefaultMintAmount(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HEZ.contract.Call(opts, &out, "defaultMintAmount") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// DefaultMintAmount is a free data retrieval call binding the contract method 0x05b23f2f. -// -// Solidity: function defaultMintAmount() view returns(uint256) -func (_HEZ *HEZSession) DefaultMintAmount() (*big.Int, error) { - return _HEZ.Contract.DefaultMintAmount(&_HEZ.CallOpts) -} - -// DefaultMintAmount is a free data retrieval call binding the contract method 0x05b23f2f. -// -// Solidity: function defaultMintAmount() view returns(uint256) -func (_HEZ *HEZCallerSession) DefaultMintAmount() (*big.Int, error) { - return _HEZ.Contract.DefaultMintAmount(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) Decimals() (uint8, error) { + return _Tokenhez.Contract.Decimals(&_Tokenhez.CallOpts) } // GetChainId is a free data retrieval call binding the contract method 0x3408e470. // // Solidity: function getChainId() pure returns(uint256 chainId) -func (_HEZ *HEZCaller) GetChainId(opts *bind.CallOpts) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) GetChainId(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "getChainId") + err := _Tokenhez.contract.Call(opts, &out, "getChainId") if err != nil { return *new(*big.Int), err @@ -501,23 +470,23 @@ func (_HEZ *HEZCaller) GetChainId(opts *bind.CallOpts) (*big.Int, error) { // GetChainId is a free data retrieval call binding the contract method 0x3408e470. // // Solidity: function getChainId() pure returns(uint256 chainId) -func (_HEZ *HEZSession) GetChainId() (*big.Int, error) { - return _HEZ.Contract.GetChainId(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) GetChainId() (*big.Int, error) { + return _Tokenhez.Contract.GetChainId(&_Tokenhez.CallOpts) } // GetChainId is a free data retrieval call binding the contract method 0x3408e470. // // Solidity: function getChainId() pure returns(uint256 chainId) -func (_HEZ *HEZCallerSession) GetChainId() (*big.Int, error) { - return _HEZ.Contract.GetChainId(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) GetChainId() (*big.Int, error) { + return _Tokenhez.Contract.GetChainId(&_Tokenhez.CallOpts) } // InitialBalance is a free data retrieval call binding the contract method 0x18369a2a. // // Solidity: function initialBalance() view returns(uint256) -func (_HEZ *HEZCaller) InitialBalance(opts *bind.CallOpts) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) InitialBalance(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "initialBalance") + err := _Tokenhez.contract.Call(opts, &out, "initialBalance") if err != nil { return *new(*big.Int), err @@ -532,23 +501,23 @@ func (_HEZ *HEZCaller) InitialBalance(opts *bind.CallOpts) (*big.Int, error) { // InitialBalance is a free data retrieval call binding the contract method 0x18369a2a. // // Solidity: function initialBalance() view returns(uint256) -func (_HEZ *HEZSession) InitialBalance() (*big.Int, error) { - return _HEZ.Contract.InitialBalance(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) InitialBalance() (*big.Int, error) { + return _Tokenhez.Contract.InitialBalance(&_Tokenhez.CallOpts) } // InitialBalance is a free data retrieval call binding the contract method 0x18369a2a. // // Solidity: function initialBalance() view returns(uint256) -func (_HEZ *HEZCallerSession) InitialBalance() (*big.Int, error) { - return _HEZ.Contract.InitialBalance(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) InitialBalance() (*big.Int, error) { + return _Tokenhez.Contract.InitialBalance(&_Tokenhez.CallOpts) } // Name is a free data retrieval call binding the contract method 0x06fdde03. // // Solidity: function name() view returns(string) -func (_HEZ *HEZCaller) Name(opts *bind.CallOpts) (string, error) { +func (_Tokenhez *TokenhezCaller) Name(opts *bind.CallOpts) (string, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "name") + err := _Tokenhez.contract.Call(opts, &out, "name") if err != nil { return *new(string), err @@ -563,23 +532,23 @@ func (_HEZ *HEZCaller) Name(opts *bind.CallOpts) (string, error) { // Name is a free data retrieval call binding the contract method 0x06fdde03. // // Solidity: function name() view returns(string) -func (_HEZ *HEZSession) Name() (string, error) { - return _HEZ.Contract.Name(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) Name() (string, error) { + return _Tokenhez.Contract.Name(&_Tokenhez.CallOpts) } // Name is a free data retrieval call binding the contract method 0x06fdde03. // // Solidity: function name() view returns(string) -func (_HEZ *HEZCallerSession) Name() (string, error) { - return _HEZ.Contract.Name(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) Name() (string, error) { + return _Tokenhez.Contract.Name(&_Tokenhez.CallOpts) } // Nonces is a free data retrieval call binding the contract method 0x7ecebe00. // // Solidity: function nonces(address ) view returns(uint256) -func (_HEZ *HEZCaller) Nonces(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) Nonces(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "nonces", arg0) + err := _Tokenhez.contract.Call(opts, &out, "nonces", arg0) if err != nil { return *new(*big.Int), err @@ -594,23 +563,23 @@ func (_HEZ *HEZCaller) Nonces(opts *bind.CallOpts, arg0 common.Address) (*big.In // Nonces is a free data retrieval call binding the contract method 0x7ecebe00. // // Solidity: function nonces(address ) view returns(uint256) -func (_HEZ *HEZSession) Nonces(arg0 common.Address) (*big.Int, error) { - return _HEZ.Contract.Nonces(&_HEZ.CallOpts, arg0) +func (_Tokenhez *TokenhezSession) Nonces(arg0 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.Nonces(&_Tokenhez.CallOpts, arg0) } // Nonces is a free data retrieval call binding the contract method 0x7ecebe00. // // Solidity: function nonces(address ) view returns(uint256) -func (_HEZ *HEZCallerSession) Nonces(arg0 common.Address) (*big.Int, error) { - return _HEZ.Contract.Nonces(&_HEZ.CallOpts, arg0) +func (_Tokenhez *TokenhezCallerSession) Nonces(arg0 common.Address) (*big.Int, error) { + return _Tokenhez.Contract.Nonces(&_Tokenhez.CallOpts, arg0) } // Symbol is a free data retrieval call binding the contract method 0x95d89b41. // // Solidity: function symbol() view returns(string) -func (_HEZ *HEZCaller) Symbol(opts *bind.CallOpts) (string, error) { +func (_Tokenhez *TokenhezCaller) Symbol(opts *bind.CallOpts) (string, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "symbol") + err := _Tokenhez.contract.Call(opts, &out, "symbol") if err != nil { return *new(string), err @@ -625,23 +594,23 @@ func (_HEZ *HEZCaller) Symbol(opts *bind.CallOpts) (string, error) { // Symbol is a free data retrieval call binding the contract method 0x95d89b41. // // Solidity: function symbol() view returns(string) -func (_HEZ *HEZSession) Symbol() (string, error) { - return _HEZ.Contract.Symbol(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) Symbol() (string, error) { + return _Tokenhez.Contract.Symbol(&_Tokenhez.CallOpts) } // Symbol is a free data retrieval call binding the contract method 0x95d89b41. // // Solidity: function symbol() view returns(string) -func (_HEZ *HEZCallerSession) Symbol() (string, error) { - return _HEZ.Contract.Symbol(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) Symbol() (string, error) { + return _Tokenhez.Contract.Symbol(&_Tokenhez.CallOpts) } // TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. // // Solidity: function totalSupply() view returns(uint256) -func (_HEZ *HEZCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { +func (_Tokenhez *TokenhezCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { var out []interface{} - err := _HEZ.contract.Call(opts, &out, "totalSupply") + err := _Tokenhez.contract.Call(opts, &out, "totalSupply") if err != nil { return *new(*big.Int), err @@ -656,167 +625,146 @@ func (_HEZ *HEZCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { // TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. // // Solidity: function totalSupply() view returns(uint256) -func (_HEZ *HEZSession) TotalSupply() (*big.Int, error) { - return _HEZ.Contract.TotalSupply(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezSession) TotalSupply() (*big.Int, error) { + return _Tokenhez.Contract.TotalSupply(&_Tokenhez.CallOpts) } // TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. // // Solidity: function totalSupply() view returns(uint256) -func (_HEZ *HEZCallerSession) TotalSupply() (*big.Int, error) { - return _HEZ.Contract.TotalSupply(&_HEZ.CallOpts) +func (_Tokenhez *TokenhezCallerSession) TotalSupply() (*big.Int, error) { + return _Tokenhez.Contract.TotalSupply(&_Tokenhez.CallOpts) } // Approve is a paid mutator transaction binding the contract method 0x095ea7b3. // // Solidity: function approve(address spender, uint256 value) returns(bool) -func (_HEZ *HEZTransactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "approve", spender, value) +func (_Tokenhez *TokenhezTransactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "approve", spender, value) } // Approve is a paid mutator transaction binding the contract method 0x095ea7b3. // // Solidity: function approve(address spender, uint256 value) returns(bool) -func (_HEZ *HEZSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Approve(&_HEZ.TransactOpts, spender, value) +func (_Tokenhez *TokenhezSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Approve(&_Tokenhez.TransactOpts, spender, value) } // Approve is a paid mutator transaction binding the contract method 0x095ea7b3. // // Solidity: function approve(address spender, uint256 value) returns(bool) -func (_HEZ *HEZTransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Approve(&_HEZ.TransactOpts, spender, value) +func (_Tokenhez *TokenhezTransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Approve(&_Tokenhez.TransactOpts, spender, value) } // Burn is a paid mutator transaction binding the contract method 0x42966c68. // // Solidity: function burn(uint256 value) returns(bool) -func (_HEZ *HEZTransactor) Burn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "burn", value) +func (_Tokenhez *TokenhezTransactor) Burn(opts *bind.TransactOpts, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "burn", value) } // Burn is a paid mutator transaction binding the contract method 0x42966c68. // // Solidity: function burn(uint256 value) returns(bool) -func (_HEZ *HEZSession) Burn(value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Burn(&_HEZ.TransactOpts, value) +func (_Tokenhez *TokenhezSession) Burn(value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Burn(&_Tokenhez.TransactOpts, value) } // Burn is a paid mutator transaction binding the contract method 0x42966c68. // // Solidity: function burn(uint256 value) returns(bool) -func (_HEZ *HEZTransactorSession) Burn(value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Burn(&_HEZ.TransactOpts, value) +func (_Tokenhez *TokenhezTransactorSession) Burn(value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Burn(&_Tokenhez.TransactOpts, value) } // Permit is a paid mutator transaction binding the contract method 0xd505accf. // // Solidity: function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZTransactor) Permit(opts *bind.TransactOpts, owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "permit", owner, spender, value, deadline, v, r, s) +func (_Tokenhez *TokenhezTransactor) Permit(opts *bind.TransactOpts, owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "permit", owner, spender, value, deadline, v, r, s) } // Permit is a paid mutator transaction binding the contract method 0xd505accf. // // Solidity: function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZSession) Permit(owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.Contract.Permit(&_HEZ.TransactOpts, owner, spender, value, deadline, v, r, s) +func (_Tokenhez *TokenhezSession) Permit(owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.Contract.Permit(&_Tokenhez.TransactOpts, owner, spender, value, deadline, v, r, s) } // Permit is a paid mutator transaction binding the contract method 0xd505accf. // // Solidity: function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZTransactorSession) Permit(owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.Contract.Permit(&_HEZ.TransactOpts, owner, spender, value, deadline, v, r, s) +func (_Tokenhez *TokenhezTransactorSession) Permit(owner common.Address, spender common.Address, value *big.Int, deadline *big.Int, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.Contract.Permit(&_Tokenhez.TransactOpts, owner, spender, value, deadline, v, r, s) } // Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. // // Solidity: function transfer(address to, uint256 value) returns(bool) -func (_HEZ *HEZTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "transfer", to, value) +func (_Tokenhez *TokenhezTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "transfer", to, value) } // Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. // // Solidity: function transfer(address to, uint256 value) returns(bool) -func (_HEZ *HEZSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Transfer(&_HEZ.TransactOpts, to, value) +func (_Tokenhez *TokenhezSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Transfer(&_Tokenhez.TransactOpts, to, value) } // Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. // // Solidity: function transfer(address to, uint256 value) returns(bool) -func (_HEZ *HEZTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.Transfer(&_HEZ.TransactOpts, to, value) +func (_Tokenhez *TokenhezTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.Transfer(&_Tokenhez.TransactOpts, to, value) } // TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. // // Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_HEZ *HEZTransactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "transferFrom", from, to, value) +func (_Tokenhez *TokenhezTransactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "transferFrom", from, to, value) } // TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. // // Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_HEZ *HEZSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.TransferFrom(&_HEZ.TransactOpts, from, to, value) +func (_Tokenhez *TokenhezSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.TransferFrom(&_Tokenhez.TransactOpts, from, to, value) } // TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. // // Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) -func (_HEZ *HEZTransactorSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { - return _HEZ.Contract.TransferFrom(&_HEZ.TransactOpts, from, to, value) +func (_Tokenhez *TokenhezTransactorSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _Tokenhez.Contract.TransferFrom(&_Tokenhez.TransactOpts, from, to, value) } // TransferWithAuthorization is a paid mutator transaction binding the contract method 0xe3ee160e. // // Solidity: function transferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZTransactor) TransferWithAuthorization(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.contract.Transact(opts, "transferWithAuthorization", from, to, value, validAfter, validBefore, nonce, v, r, s) +func (_Tokenhez *TokenhezTransactor) TransferWithAuthorization(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.contract.Transact(opts, "transferWithAuthorization", from, to, value, validAfter, validBefore, nonce, v, r, s) } // TransferWithAuthorization is a paid mutator transaction binding the contract method 0xe3ee160e. // // Solidity: function transferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZSession) TransferWithAuthorization(from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.Contract.TransferWithAuthorization(&_HEZ.TransactOpts, from, to, value, validAfter, validBefore, nonce, v, r, s) +func (_Tokenhez *TokenhezSession) TransferWithAuthorization(from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.Contract.TransferWithAuthorization(&_Tokenhez.TransactOpts, from, to, value, validAfter, validBefore, nonce, v, r, s) } // TransferWithAuthorization is a paid mutator transaction binding the contract method 0xe3ee160e. // // Solidity: function transferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) returns() -func (_HEZ *HEZTransactorSession) TransferWithAuthorization(from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { - return _HEZ.Contract.TransferWithAuthorization(&_HEZ.TransactOpts, from, to, value, validAfter, validBefore, nonce, v, r, s) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_HEZ *HEZTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HEZ.contract.RawTransact(opts, nil) // calldata is disallowed for receive function -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_HEZ *HEZSession) Receive() (*types.Transaction, error) { - return _HEZ.Contract.Receive(&_HEZ.TransactOpts) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_HEZ *HEZTransactorSession) Receive() (*types.Transaction, error) { - return _HEZ.Contract.Receive(&_HEZ.TransactOpts) +func (_Tokenhez *TokenhezTransactorSession) TransferWithAuthorization(from common.Address, to common.Address, value *big.Int, validAfter *big.Int, validBefore *big.Int, nonce [32]byte, v uint8, r [32]byte, s [32]byte) (*types.Transaction, error) { + return _Tokenhez.Contract.TransferWithAuthorization(&_Tokenhez.TransactOpts, from, to, value, validAfter, validBefore, nonce, v, r, s) } -// HEZApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the HEZ contract. -type HEZApprovalIterator struct { - Event *HEZApproval // Event containing the contract specifics and raw log +// TokenhezApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the Tokenhez contract. +type TokenhezApprovalIterator struct { + Event *TokenhezApproval // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -830,7 +778,7 @@ type HEZApprovalIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HEZApprovalIterator) Next() bool { +func (it *TokenhezApprovalIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -839,7 +787,7 @@ func (it *HEZApprovalIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HEZApproval) + it.Event = new(TokenhezApproval) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -854,7 +802,7 @@ func (it *HEZApprovalIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HEZApproval) + it.Event = new(TokenhezApproval) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -870,19 +818,19 @@ func (it *HEZApprovalIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HEZApprovalIterator) Error() error { +func (it *TokenhezApprovalIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HEZApprovalIterator) Close() error { +func (it *TokenhezApprovalIterator) Close() error { it.sub.Unsubscribe() return nil } -// HEZApproval represents a Approval event raised by the HEZ contract. -type HEZApproval struct { +// TokenhezApproval represents a Approval event raised by the Tokenhez contract. +type TokenhezApproval struct { Owner common.Address Spender common.Address Value *big.Int @@ -892,7 +840,7 @@ type HEZApproval struct { // FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. // // Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HEZ *HEZFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*HEZApprovalIterator, error) { +func (_Tokenhez *TokenhezFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*TokenhezApprovalIterator, error) { var ownerRule []interface{} for _, ownerItem := range owner { @@ -903,17 +851,17 @@ func (_HEZ *HEZFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Ad spenderRule = append(spenderRule, spenderItem) } - logs, sub, err := _HEZ.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + logs, sub, err := _Tokenhez.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) if err != nil { return nil, err } - return &HEZApprovalIterator{contract: _HEZ.contract, event: "Approval", logs: logs, sub: sub}, nil + return &TokenhezApprovalIterator{contract: _Tokenhez.contract, event: "Approval", logs: logs, sub: sub}, nil } // WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. // // Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HEZ *HEZFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *HEZApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { +func (_Tokenhez *TokenhezFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *TokenhezApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { var ownerRule []interface{} for _, ownerItem := range owner { @@ -924,7 +872,7 @@ func (_HEZ *HEZFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *HEZApp spenderRule = append(spenderRule, spenderItem) } - logs, sub, err := _HEZ.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + logs, sub, err := _Tokenhez.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) if err != nil { return nil, err } @@ -934,8 +882,8 @@ func (_HEZ *HEZFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *HEZApp select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HEZApproval) - if err := _HEZ.contract.UnpackLog(event, "Approval", log); err != nil { + event := new(TokenhezApproval) + if err := _Tokenhez.contract.UnpackLog(event, "Approval", log); err != nil { return err } event.Raw = log @@ -959,18 +907,18 @@ func (_HEZ *HEZFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *HEZApp // ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. // // Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HEZ *HEZFilterer) ParseApproval(log types.Log) (*HEZApproval, error) { - event := new(HEZApproval) - if err := _HEZ.contract.UnpackLog(event, "Approval", log); err != nil { +func (_Tokenhez *TokenhezFilterer) ParseApproval(log types.Log) (*TokenhezApproval, error) { + event := new(TokenhezApproval) + if err := _Tokenhez.contract.UnpackLog(event, "Approval", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HEZAuthorizationUsedIterator is returned from FilterAuthorizationUsed and is used to iterate over the raw logs and unpacked data for AuthorizationUsed events raised by the HEZ contract. -type HEZAuthorizationUsedIterator struct { - Event *HEZAuthorizationUsed // Event containing the contract specifics and raw log +// TokenhezAuthorizationUsedIterator is returned from FilterAuthorizationUsed and is used to iterate over the raw logs and unpacked data for AuthorizationUsed events raised by the Tokenhez contract. +type TokenhezAuthorizationUsedIterator struct { + Event *TokenhezAuthorizationUsed // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -984,7 +932,7 @@ type HEZAuthorizationUsedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HEZAuthorizationUsedIterator) Next() bool { +func (it *TokenhezAuthorizationUsedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -993,7 +941,7 @@ func (it *HEZAuthorizationUsedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HEZAuthorizationUsed) + it.Event = new(TokenhezAuthorizationUsed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1008,7 +956,7 @@ func (it *HEZAuthorizationUsedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HEZAuthorizationUsed) + it.Event = new(TokenhezAuthorizationUsed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1024,19 +972,19 @@ func (it *HEZAuthorizationUsedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HEZAuthorizationUsedIterator) Error() error { +func (it *TokenhezAuthorizationUsedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HEZAuthorizationUsedIterator) Close() error { +func (it *TokenhezAuthorizationUsedIterator) Close() error { it.sub.Unsubscribe() return nil } -// HEZAuthorizationUsed represents a AuthorizationUsed event raised by the HEZ contract. -type HEZAuthorizationUsed struct { +// TokenhezAuthorizationUsed represents a AuthorizationUsed event raised by the Tokenhez contract. +type TokenhezAuthorizationUsed struct { Authorizer common.Address Nonce [32]byte Raw types.Log // Blockchain specific contextual infos @@ -1045,7 +993,7 @@ type HEZAuthorizationUsed struct { // FilterAuthorizationUsed is a free log retrieval operation binding the contract event 0x98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a5. // // Solidity: event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce) -func (_HEZ *HEZFilterer) FilterAuthorizationUsed(opts *bind.FilterOpts, authorizer []common.Address, nonce [][32]byte) (*HEZAuthorizationUsedIterator, error) { +func (_Tokenhez *TokenhezFilterer) FilterAuthorizationUsed(opts *bind.FilterOpts, authorizer []common.Address, nonce [][32]byte) (*TokenhezAuthorizationUsedIterator, error) { var authorizerRule []interface{} for _, authorizerItem := range authorizer { @@ -1056,17 +1004,17 @@ func (_HEZ *HEZFilterer) FilterAuthorizationUsed(opts *bind.FilterOpts, authoriz nonceRule = append(nonceRule, nonceItem) } - logs, sub, err := _HEZ.contract.FilterLogs(opts, "AuthorizationUsed", authorizerRule, nonceRule) + logs, sub, err := _Tokenhez.contract.FilterLogs(opts, "AuthorizationUsed", authorizerRule, nonceRule) if err != nil { return nil, err } - return &HEZAuthorizationUsedIterator{contract: _HEZ.contract, event: "AuthorizationUsed", logs: logs, sub: sub}, nil + return &TokenhezAuthorizationUsedIterator{contract: _Tokenhez.contract, event: "AuthorizationUsed", logs: logs, sub: sub}, nil } // WatchAuthorizationUsed is a free log subscription operation binding the contract event 0x98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a5. // // Solidity: event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce) -func (_HEZ *HEZFilterer) WatchAuthorizationUsed(opts *bind.WatchOpts, sink chan<- *HEZAuthorizationUsed, authorizer []common.Address, nonce [][32]byte) (event.Subscription, error) { +func (_Tokenhez *TokenhezFilterer) WatchAuthorizationUsed(opts *bind.WatchOpts, sink chan<- *TokenhezAuthorizationUsed, authorizer []common.Address, nonce [][32]byte) (event.Subscription, error) { var authorizerRule []interface{} for _, authorizerItem := range authorizer { @@ -1077,7 +1025,7 @@ func (_HEZ *HEZFilterer) WatchAuthorizationUsed(opts *bind.WatchOpts, sink chan< nonceRule = append(nonceRule, nonceItem) } - logs, sub, err := _HEZ.contract.WatchLogs(opts, "AuthorizationUsed", authorizerRule, nonceRule) + logs, sub, err := _Tokenhez.contract.WatchLogs(opts, "AuthorizationUsed", authorizerRule, nonceRule) if err != nil { return nil, err } @@ -1087,8 +1035,8 @@ func (_HEZ *HEZFilterer) WatchAuthorizationUsed(opts *bind.WatchOpts, sink chan< select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HEZAuthorizationUsed) - if err := _HEZ.contract.UnpackLog(event, "AuthorizationUsed", log); err != nil { + event := new(TokenhezAuthorizationUsed) + if err := _Tokenhez.contract.UnpackLog(event, "AuthorizationUsed", log); err != nil { return err } event.Raw = log @@ -1112,18 +1060,18 @@ func (_HEZ *HEZFilterer) WatchAuthorizationUsed(opts *bind.WatchOpts, sink chan< // ParseAuthorizationUsed is a log parse operation binding the contract event 0x98de503528ee59b575ef0c0a2576a82497bfc029a5685b209e9ec333479b10a5. // // Solidity: event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce) -func (_HEZ *HEZFilterer) ParseAuthorizationUsed(log types.Log) (*HEZAuthorizationUsed, error) { - event := new(HEZAuthorizationUsed) - if err := _HEZ.contract.UnpackLog(event, "AuthorizationUsed", log); err != nil { +func (_Tokenhez *TokenhezFilterer) ParseAuthorizationUsed(log types.Log) (*TokenhezAuthorizationUsed, error) { + event := new(TokenhezAuthorizationUsed) + if err := _Tokenhez.contract.UnpackLog(event, "AuthorizationUsed", log); err != nil { return nil, err } event.Raw = log return event, nil } -// HEZTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the HEZ contract. -type HEZTransferIterator struct { - Event *HEZTransfer // Event containing the contract specifics and raw log +// TokenhezTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the Tokenhez contract. +type TokenhezTransferIterator struct { + Event *TokenhezTransfer // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1137,7 +1085,7 @@ type HEZTransferIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *HEZTransferIterator) Next() bool { +func (it *TokenhezTransferIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1146,7 +1094,7 @@ func (it *HEZTransferIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(HEZTransfer) + it.Event = new(TokenhezTransfer) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1161,7 +1109,7 @@ func (it *HEZTransferIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(HEZTransfer) + it.Event = new(TokenhezTransfer) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1177,19 +1125,19 @@ func (it *HEZTransferIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *HEZTransferIterator) Error() error { +func (it *TokenhezTransferIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *HEZTransferIterator) Close() error { +func (it *TokenhezTransferIterator) Close() error { it.sub.Unsubscribe() return nil } -// HEZTransfer represents a Transfer event raised by the HEZ contract. -type HEZTransfer struct { +// TokenhezTransfer represents a Transfer event raised by the Tokenhez contract. +type TokenhezTransfer struct { From common.Address To common.Address Value *big.Int @@ -1199,7 +1147,7 @@ type HEZTransfer struct { // FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. // // Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HEZ *HEZFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*HEZTransferIterator, error) { +func (_Tokenhez *TokenhezFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*TokenhezTransferIterator, error) { var fromRule []interface{} for _, fromItem := range from { @@ -1210,17 +1158,17 @@ func (_HEZ *HEZFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Add toRule = append(toRule, toItem) } - logs, sub, err := _HEZ.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + logs, sub, err := _Tokenhez.contract.FilterLogs(opts, "Transfer", fromRule, toRule) if err != nil { return nil, err } - return &HEZTransferIterator{contract: _HEZ.contract, event: "Transfer", logs: logs, sub: sub}, nil + return &TokenhezTransferIterator{contract: _Tokenhez.contract, event: "Transfer", logs: logs, sub: sub}, nil } // WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. // // Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HEZ *HEZFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *HEZTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { +func (_Tokenhez *TokenhezFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *TokenhezTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { var fromRule []interface{} for _, fromItem := range from { @@ -1231,7 +1179,7 @@ func (_HEZ *HEZFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *HEZTra toRule = append(toRule, toItem) } - logs, sub, err := _HEZ.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + logs, sub, err := _Tokenhez.contract.WatchLogs(opts, "Transfer", fromRule, toRule) if err != nil { return nil, err } @@ -1241,8 +1189,8 @@ func (_HEZ *HEZFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *HEZTra select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(HEZTransfer) - if err := _HEZ.contract.UnpackLog(event, "Transfer", log); err != nil { + event := new(TokenhezTransfer) + if err := _Tokenhez.contract.UnpackLog(event, "Transfer", log); err != nil { return err } event.Raw = log @@ -1266,9 +1214,9 @@ func (_HEZ *HEZFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *HEZTra // ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. // // Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HEZ *HEZFilterer) ParseTransfer(log types.Log) (*HEZTransfer, error) { - event := new(HEZTransfer) - if err := _HEZ.contract.UnpackLog(event, "Transfer", log); err != nil { +func (_Tokenhez *TokenhezFilterer) ParseTransfer(log types.Log) (*TokenhezTransfer, error) { + event := new(TokenhezTransfer) + if err := _Tokenhez.contract.UnpackLog(event, "Transfer", log); err != nil { return nil, err } event.Raw = log diff --git a/eth/contracts/update.sh b/eth/contracts/update.sh index cfda88532..df723ca59 100755 --- a/eth/contracts/update.sh +++ b/eth/contracts/update.sh @@ -3,25 +3,18 @@ set -e gen() { - local name=$1 - local pkg=$2 + local pkg=$1 + local package=$2 local folder=$3 if [ -z "$3" ]; then - folder=$name + folder=$package fi - jq .abi "${CONTRACTS}/artifacts/contracts/${name}/${pkg}.sol/${pkg}.json" > /tmp/${name}.abi - abigen --abi /tmp/${name}.abi --pkg=${pkg} --out=${folder}/${pkg}.go + jq .abi "abi/${pkg}.json" > /tmp/${package}.abi + abigen --abi /tmp/${package}.abi --pkg=${package} --out=${folder}/${package}.go } -if [ "$1" = "" ]; then - echo "Usage: $0 CONTRACTS_REPO_PATH" - exit 1 -fi - -CONTRACTS="$1" - -gen hermez Hermez -gen auction HermezAuctionProtocol -gen withdrawalDelayer WithdrawalDelayer -gen HEZ HEZ tokenHEZ +gen Hermez hermez +gen HermezAuctionProtocol auction +gen WithdrawalDelayer withdrawaldelayer +gen HEZ tokenhez diff --git a/eth/contracts/withdrawalDelayer/WithdrawalDelayer.go b/eth/contracts/withdrawaldelayer/withdrawaldelayer.go similarity index 69% rename from eth/contracts/withdrawalDelayer/WithdrawalDelayer.go rename to eth/contracts/withdrawaldelayer/withdrawaldelayer.go index a30ff5592..d9a1d2c18 100644 --- a/eth/contracts/withdrawalDelayer/WithdrawalDelayer.go +++ b/eth/contracts/withdrawaldelayer/withdrawaldelayer.go @@ -1,7 +1,7 @@ // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package WithdrawalDelayer +package withdrawaldelayer import ( "math/big" @@ -26,107 +26,107 @@ var ( _ = event.NewSubscription ) -// WithdrawalDelayerABI is the input ABI used to generate the binding from. -const WithdrawalDelayerABI = "[{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"_initialWithdrawalDelay\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"_initialHermezRollup\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_initialHermezGovernanceAddress\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"_initialEmergencyCouncil\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTimestamp\",\"type\":\"uint64\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"EmergencyModeEnabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"who\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EscapeHatchWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"initialWithdrawalDelay\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initialHermezGovernanceAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initialEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"InitializeWithdrawalDelayerEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"NewEmergencyCouncil\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newHermezGovernanceAddress\",\"type\":\"address\"}],\"name\":\"NewHermezGovernanceAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"withdrawalDelay\",\"type\":\"uint64\"}],\"name\":\"NewWithdrawalDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"}],\"name\":\"Withdraw\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_EMERGENCY_MODE_TIME\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_WITHDRAWAL_DELAY\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"_newWithdrawalDelay\",\"type\":\"uint64\"}],\"name\":\"changeWithdrawalDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimEmergencyCouncil\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint192\",\"name\":\"_amount\",\"type\":\"uint192\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"depositInfo\",\"outputs\":[{\"internalType\":\"uint192\",\"name\":\"\",\"type\":\"uint192\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"deposits\",\"outputs\":[{\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"},{\"internalType\":\"uint64\",\"name\":\"depositTimestamp\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enableEmergencyMode\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"escapeHatchWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEmergencyCouncil\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEmergencyModeStartingTime\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHermezGovernanceAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWithdrawalDelay\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hermezRollupAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isEmergencyMode\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingEmergencyCouncil\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingGovernance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"newEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"transferEmergencyCouncil\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"withdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" +// WithdrawaldelayerABI is the input ABI used to generate the binding from. +const WithdrawaldelayerABI = "[{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"_initialWithdrawalDelay\",\"type\":\"uint64\"},{\"internalType\":\"address\",\"name\":\"_initialHermezRollup\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_initialHermezGovernanceAddress\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"_initialEmergencyCouncil\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTimestamp\",\"type\":\"uint64\"}],\"name\":\"Deposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"EmergencyModeEnabled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"who\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"EscapeHatchWithdrawal\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"initialWithdrawalDelay\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initialHermezGovernanceAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"initialEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"InitializeWithdrawalDelayerEvent\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"NewEmergencyCouncil\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newHermezGovernanceAddress\",\"type\":\"address\"}],\"name\":\"NewHermezGovernanceAddress\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"withdrawalDelay\",\"type\":\"uint64\"}],\"name\":\"NewWithdrawalDelay\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"}],\"name\":\"Withdraw\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"MAX_EMERGENCY_MODE_TIME\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"MAX_WITHDRAWAL_DELAY\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"_newWithdrawalDelay\",\"type\":\"uint64\"}],\"name\":\"changeWithdrawalDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimEmergencyCouncil\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"claimGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint192\",\"name\":\"_amount\",\"type\":\"uint192\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"depositInfo\",\"outputs\":[{\"internalType\":\"uint192\",\"name\":\"\",\"type\":\"uint192\"},{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"deposits\",\"outputs\":[{\"internalType\":\"uint192\",\"name\":\"amount\",\"type\":\"uint192\"},{\"internalType\":\"uint64\",\"name\":\"depositTimestamp\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"enableEmergencyMode\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"escapeHatchWithdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEmergencyCouncil\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getEmergencyModeStartingTime\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getHermezGovernanceAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getWithdrawalDelay\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"\",\"type\":\"uint64\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"hermezRollupAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"isEmergencyMode\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingEmergencyCouncil\",\"outputs\":[{\"internalType\":\"addresspayable\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"pendingGovernance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"newEmergencyCouncil\",\"type\":\"address\"}],\"name\":\"transferEmergencyCouncil\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"addresspayable\",\"name\":\"_owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"withdrawal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" -// WithdrawalDelayer is an auto generated Go binding around an Ethereum contract. -type WithdrawalDelayer struct { - WithdrawalDelayerCaller // Read-only binding to the contract - WithdrawalDelayerTransactor // Write-only binding to the contract - WithdrawalDelayerFilterer // Log filterer for contract events +// Withdrawaldelayer is an auto generated Go binding around an Ethereum contract. +type Withdrawaldelayer struct { + WithdrawaldelayerCaller // Read-only binding to the contract + WithdrawaldelayerTransactor // Write-only binding to the contract + WithdrawaldelayerFilterer // Log filterer for contract events } -// WithdrawalDelayerCaller is an auto generated read-only Go binding around an Ethereum contract. -type WithdrawalDelayerCaller struct { +// WithdrawaldelayerCaller is an auto generated read-only Go binding around an Ethereum contract. +type WithdrawaldelayerCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// WithdrawalDelayerTransactor is an auto generated write-only Go binding around an Ethereum contract. -type WithdrawalDelayerTransactor struct { +// WithdrawaldelayerTransactor is an auto generated write-only Go binding around an Ethereum contract. +type WithdrawaldelayerTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// WithdrawalDelayerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type WithdrawalDelayerFilterer struct { +// WithdrawaldelayerFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type WithdrawaldelayerFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// WithdrawalDelayerSession is an auto generated Go binding around an Ethereum contract, +// WithdrawaldelayerSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. -type WithdrawalDelayerSession struct { - Contract *WithdrawalDelayer // Generic contract binding to set the session for +type WithdrawaldelayerSession struct { + Contract *Withdrawaldelayer // Generic contract binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// WithdrawalDelayerCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// WithdrawaldelayerCallerSession is an auto generated read-only Go binding around an Ethereum contract, // with pre-set call options. -type WithdrawalDelayerCallerSession struct { - Contract *WithdrawalDelayerCaller // Generic contract caller binding to set the session for +type WithdrawaldelayerCallerSession struct { + Contract *WithdrawaldelayerCaller // Generic contract caller binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session } -// WithdrawalDelayerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// WithdrawaldelayerTransactorSession is an auto generated write-only Go binding around an Ethereum contract, // with pre-set transact options. -type WithdrawalDelayerTransactorSession struct { - Contract *WithdrawalDelayerTransactor // Generic contract transactor binding to set the session for +type WithdrawaldelayerTransactorSession struct { + Contract *WithdrawaldelayerTransactor // Generic contract transactor binding to set the session for TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// WithdrawalDelayerRaw is an auto generated low-level Go binding around an Ethereum contract. -type WithdrawalDelayerRaw struct { - Contract *WithdrawalDelayer // Generic contract binding to access the raw methods on +// WithdrawaldelayerRaw is an auto generated low-level Go binding around an Ethereum contract. +type WithdrawaldelayerRaw struct { + Contract *Withdrawaldelayer // Generic contract binding to access the raw methods on } -// WithdrawalDelayerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type WithdrawalDelayerCallerRaw struct { - Contract *WithdrawalDelayerCaller // Generic read-only contract binding to access the raw methods on +// WithdrawaldelayerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type WithdrawaldelayerCallerRaw struct { + Contract *WithdrawaldelayerCaller // Generic read-only contract binding to access the raw methods on } -// WithdrawalDelayerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type WithdrawalDelayerTransactorRaw struct { - Contract *WithdrawalDelayerTransactor // Generic write-only contract binding to access the raw methods on +// WithdrawaldelayerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type WithdrawaldelayerTransactorRaw struct { + Contract *WithdrawaldelayerTransactor // Generic write-only contract binding to access the raw methods on } -// NewWithdrawalDelayer creates a new instance of WithdrawalDelayer, bound to a specific deployed contract. -func NewWithdrawalDelayer(address common.Address, backend bind.ContractBackend) (*WithdrawalDelayer, error) { - contract, err := bindWithdrawalDelayer(address, backend, backend, backend) +// NewWithdrawaldelayer creates a new instance of Withdrawaldelayer, bound to a specific deployed contract. +func NewWithdrawaldelayer(address common.Address, backend bind.ContractBackend) (*Withdrawaldelayer, error) { + contract, err := bindWithdrawaldelayer(address, backend, backend, backend) if err != nil { return nil, err } - return &WithdrawalDelayer{WithdrawalDelayerCaller: WithdrawalDelayerCaller{contract: contract}, WithdrawalDelayerTransactor: WithdrawalDelayerTransactor{contract: contract}, WithdrawalDelayerFilterer: WithdrawalDelayerFilterer{contract: contract}}, nil + return &Withdrawaldelayer{WithdrawaldelayerCaller: WithdrawaldelayerCaller{contract: contract}, WithdrawaldelayerTransactor: WithdrawaldelayerTransactor{contract: contract}, WithdrawaldelayerFilterer: WithdrawaldelayerFilterer{contract: contract}}, nil } -// NewWithdrawalDelayerCaller creates a new read-only instance of WithdrawalDelayer, bound to a specific deployed contract. -func NewWithdrawalDelayerCaller(address common.Address, caller bind.ContractCaller) (*WithdrawalDelayerCaller, error) { - contract, err := bindWithdrawalDelayer(address, caller, nil, nil) +// NewWithdrawaldelayerCaller creates a new read-only instance of Withdrawaldelayer, bound to a specific deployed contract. +func NewWithdrawaldelayerCaller(address common.Address, caller bind.ContractCaller) (*WithdrawaldelayerCaller, error) { + contract, err := bindWithdrawaldelayer(address, caller, nil, nil) if err != nil { return nil, err } - return &WithdrawalDelayerCaller{contract: contract}, nil + return &WithdrawaldelayerCaller{contract: contract}, nil } -// NewWithdrawalDelayerTransactor creates a new write-only instance of WithdrawalDelayer, bound to a specific deployed contract. -func NewWithdrawalDelayerTransactor(address common.Address, transactor bind.ContractTransactor) (*WithdrawalDelayerTransactor, error) { - contract, err := bindWithdrawalDelayer(address, nil, transactor, nil) +// NewWithdrawaldelayerTransactor creates a new write-only instance of Withdrawaldelayer, bound to a specific deployed contract. +func NewWithdrawaldelayerTransactor(address common.Address, transactor bind.ContractTransactor) (*WithdrawaldelayerTransactor, error) { + contract, err := bindWithdrawaldelayer(address, nil, transactor, nil) if err != nil { return nil, err } - return &WithdrawalDelayerTransactor{contract: contract}, nil + return &WithdrawaldelayerTransactor{contract: contract}, nil } -// NewWithdrawalDelayerFilterer creates a new log filterer instance of WithdrawalDelayer, bound to a specific deployed contract. -func NewWithdrawalDelayerFilterer(address common.Address, filterer bind.ContractFilterer) (*WithdrawalDelayerFilterer, error) { - contract, err := bindWithdrawalDelayer(address, nil, nil, filterer) +// NewWithdrawaldelayerFilterer creates a new log filterer instance of Withdrawaldelayer, bound to a specific deployed contract. +func NewWithdrawaldelayerFilterer(address common.Address, filterer bind.ContractFilterer) (*WithdrawaldelayerFilterer, error) { + contract, err := bindWithdrawaldelayer(address, nil, nil, filterer) if err != nil { return nil, err } - return &WithdrawalDelayerFilterer{contract: contract}, nil + return &WithdrawaldelayerFilterer{contract: contract}, nil } -// bindWithdrawalDelayer binds a generic wrapper to an already deployed contract. -func bindWithdrawalDelayer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(WithdrawalDelayerABI)) +// bindWithdrawaldelayer binds a generic wrapper to an already deployed contract. +func bindWithdrawaldelayer(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(WithdrawaldelayerABI)) if err != nil { return nil, err } @@ -137,46 +137,46 @@ func bindWithdrawalDelayer(address common.Address, caller bind.ContractCaller, t // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_WithdrawalDelayer *WithdrawalDelayerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _WithdrawalDelayer.Contract.WithdrawalDelayerCaller.contract.Call(opts, result, method, params...) +func (_Withdrawaldelayer *WithdrawaldelayerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Withdrawaldelayer.Contract.WithdrawaldelayerCaller.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_WithdrawalDelayer *WithdrawalDelayerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.WithdrawalDelayerTransactor.contract.Transfer(opts) +func (_Withdrawaldelayer *WithdrawaldelayerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.WithdrawaldelayerTransactor.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_WithdrawalDelayer *WithdrawalDelayerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.WithdrawalDelayerTransactor.contract.Transact(opts, method, params...) +func (_Withdrawaldelayer *WithdrawaldelayerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.WithdrawaldelayerTransactor.contract.Transact(opts, method, params...) } // Call invokes the (constant) contract method with params as input values and // sets the output to result. The result type might be a single field for simple // returns, a slice of interfaces for anonymous returns and a struct for named // returns. -func (_WithdrawalDelayer *WithdrawalDelayerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _WithdrawalDelayer.Contract.contract.Call(opts, result, method, params...) +func (_Withdrawaldelayer *WithdrawaldelayerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Withdrawaldelayer.Contract.contract.Call(opts, result, method, params...) } // Transfer initiates a plain transaction to move funds to the contract, calling // its default method if one is available. -func (_WithdrawalDelayer *WithdrawalDelayerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.contract.Transfer(opts) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_WithdrawalDelayer *WithdrawalDelayerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.contract.Transact(opts, method, params...) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.contract.Transact(opts, method, params...) } // MAXEMERGENCYMODETIME is a free data retrieval call binding the contract method 0xb4b8e39d. // // Solidity: function MAX_EMERGENCY_MODE_TIME() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) MAXEMERGENCYMODETIME(opts *bind.CallOpts) (uint64, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) MAXEMERGENCYMODETIME(opts *bind.CallOpts) (uint64, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "MAX_EMERGENCY_MODE_TIME") + err := _Withdrawaldelayer.contract.Call(opts, &out, "MAX_EMERGENCY_MODE_TIME") if err != nil { return *new(uint64), err @@ -191,23 +191,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) MAXEMERGENCYMODETIME(opts *bi // MAXEMERGENCYMODETIME is a free data retrieval call binding the contract method 0xb4b8e39d. // // Solidity: function MAX_EMERGENCY_MODE_TIME() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerSession) MAXEMERGENCYMODETIME() (uint64, error) { - return _WithdrawalDelayer.Contract.MAXEMERGENCYMODETIME(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) MAXEMERGENCYMODETIME() (uint64, error) { + return _Withdrawaldelayer.Contract.MAXEMERGENCYMODETIME(&_Withdrawaldelayer.CallOpts) } // MAXEMERGENCYMODETIME is a free data retrieval call binding the contract method 0xb4b8e39d. // // Solidity: function MAX_EMERGENCY_MODE_TIME() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) MAXEMERGENCYMODETIME() (uint64, error) { - return _WithdrawalDelayer.Contract.MAXEMERGENCYMODETIME(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) MAXEMERGENCYMODETIME() (uint64, error) { + return _Withdrawaldelayer.Contract.MAXEMERGENCYMODETIME(&_Withdrawaldelayer.CallOpts) } // MAXWITHDRAWALDELAY is a free data retrieval call binding the contract method 0xa238f9df. // // Solidity: function MAX_WITHDRAWAL_DELAY() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) MAXWITHDRAWALDELAY(opts *bind.CallOpts) (uint64, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) MAXWITHDRAWALDELAY(opts *bind.CallOpts) (uint64, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "MAX_WITHDRAWAL_DELAY") + err := _Withdrawaldelayer.contract.Call(opts, &out, "MAX_WITHDRAWAL_DELAY") if err != nil { return *new(uint64), err @@ -222,23 +222,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) MAXWITHDRAWALDELAY(opts *bind // MAXWITHDRAWALDELAY is a free data retrieval call binding the contract method 0xa238f9df. // // Solidity: function MAX_WITHDRAWAL_DELAY() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerSession) MAXWITHDRAWALDELAY() (uint64, error) { - return _WithdrawalDelayer.Contract.MAXWITHDRAWALDELAY(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) MAXWITHDRAWALDELAY() (uint64, error) { + return _Withdrawaldelayer.Contract.MAXWITHDRAWALDELAY(&_Withdrawaldelayer.CallOpts) } // MAXWITHDRAWALDELAY is a free data retrieval call binding the contract method 0xa238f9df. // // Solidity: function MAX_WITHDRAWAL_DELAY() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) MAXWITHDRAWALDELAY() (uint64, error) { - return _WithdrawalDelayer.Contract.MAXWITHDRAWALDELAY(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) MAXWITHDRAWALDELAY() (uint64, error) { + return _Withdrawaldelayer.Contract.MAXWITHDRAWALDELAY(&_Withdrawaldelayer.CallOpts) } // DepositInfo is a free data retrieval call binding the contract method 0x493b0170. // // Solidity: function depositInfo(address _owner, address _token) view returns(uint192, uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) DepositInfo(opts *bind.CallOpts, _owner common.Address, _token common.Address) (*big.Int, uint64, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) DepositInfo(opts *bind.CallOpts, _owner common.Address, _token common.Address) (*big.Int, uint64, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "depositInfo", _owner, _token) + err := _Withdrawaldelayer.contract.Call(opts, &out, "depositInfo", _owner, _token) if err != nil { return *new(*big.Int), *new(uint64), err @@ -254,26 +254,26 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) DepositInfo(opts *bind.CallOp // DepositInfo is a free data retrieval call binding the contract method 0x493b0170. // // Solidity: function depositInfo(address _owner, address _token) view returns(uint192, uint64) -func (_WithdrawalDelayer *WithdrawalDelayerSession) DepositInfo(_owner common.Address, _token common.Address) (*big.Int, uint64, error) { - return _WithdrawalDelayer.Contract.DepositInfo(&_WithdrawalDelayer.CallOpts, _owner, _token) +func (_Withdrawaldelayer *WithdrawaldelayerSession) DepositInfo(_owner common.Address, _token common.Address) (*big.Int, uint64, error) { + return _Withdrawaldelayer.Contract.DepositInfo(&_Withdrawaldelayer.CallOpts, _owner, _token) } // DepositInfo is a free data retrieval call binding the contract method 0x493b0170. // // Solidity: function depositInfo(address _owner, address _token) view returns(uint192, uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) DepositInfo(_owner common.Address, _token common.Address) (*big.Int, uint64, error) { - return _WithdrawalDelayer.Contract.DepositInfo(&_WithdrawalDelayer.CallOpts, _owner, _token) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) DepositInfo(_owner common.Address, _token common.Address) (*big.Int, uint64, error) { + return _Withdrawaldelayer.Contract.DepositInfo(&_Withdrawaldelayer.CallOpts, _owner, _token) } // Deposits is a free data retrieval call binding the contract method 0x3d4dff7b. // // Solidity: function deposits(bytes32 ) view returns(uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) Deposits(opts *bind.CallOpts, arg0 [32]byte) (struct { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) Deposits(opts *bind.CallOpts, arg0 [32]byte) (struct { Amount *big.Int DepositTimestamp uint64 }, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "deposits", arg0) + err := _Withdrawaldelayer.contract.Call(opts, &out, "deposits", arg0) outstruct := new(struct { Amount *big.Int @@ -293,29 +293,29 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) Deposits(opts *bind.CallOpts, // Deposits is a free data retrieval call binding the contract method 0x3d4dff7b. // // Solidity: function deposits(bytes32 ) view returns(uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerSession) Deposits(arg0 [32]byte) (struct { +func (_Withdrawaldelayer *WithdrawaldelayerSession) Deposits(arg0 [32]byte) (struct { Amount *big.Int DepositTimestamp uint64 }, error) { - return _WithdrawalDelayer.Contract.Deposits(&_WithdrawalDelayer.CallOpts, arg0) + return _Withdrawaldelayer.Contract.Deposits(&_Withdrawaldelayer.CallOpts, arg0) } // Deposits is a free data retrieval call binding the contract method 0x3d4dff7b. // // Solidity: function deposits(bytes32 ) view returns(uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) Deposits(arg0 [32]byte) (struct { +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) Deposits(arg0 [32]byte) (struct { Amount *big.Int DepositTimestamp uint64 }, error) { - return _WithdrawalDelayer.Contract.Deposits(&_WithdrawalDelayer.CallOpts, arg0) + return _Withdrawaldelayer.Contract.Deposits(&_Withdrawaldelayer.CallOpts, arg0) } // GetEmergencyCouncil is a free data retrieval call binding the contract method 0x99ef11c5. // // Solidity: function getEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetEmergencyCouncil(opts *bind.CallOpts) (common.Address, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) GetEmergencyCouncil(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "getEmergencyCouncil") + err := _Withdrawaldelayer.contract.Call(opts, &out, "getEmergencyCouncil") if err != nil { return *new(common.Address), err @@ -330,23 +330,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetEmergencyCouncil(opts *bin // GetEmergencyCouncil is a free data retrieval call binding the contract method 0x99ef11c5. // // Solidity: function getEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerSession) GetEmergencyCouncil() (common.Address, error) { - return _WithdrawalDelayer.Contract.GetEmergencyCouncil(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) GetEmergencyCouncil() (common.Address, error) { + return _Withdrawaldelayer.Contract.GetEmergencyCouncil(&_Withdrawaldelayer.CallOpts) } // GetEmergencyCouncil is a free data retrieval call binding the contract method 0x99ef11c5. // // Solidity: function getEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) GetEmergencyCouncil() (common.Address, error) { - return _WithdrawalDelayer.Contract.GetEmergencyCouncil(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) GetEmergencyCouncil() (common.Address, error) { + return _Withdrawaldelayer.Contract.GetEmergencyCouncil(&_Withdrawaldelayer.CallOpts) } // GetEmergencyModeStartingTime is a free data retrieval call binding the contract method 0x668cdd67. // // Solidity: function getEmergencyModeStartingTime() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetEmergencyModeStartingTime(opts *bind.CallOpts) (uint64, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) GetEmergencyModeStartingTime(opts *bind.CallOpts) (uint64, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "getEmergencyModeStartingTime") + err := _Withdrawaldelayer.contract.Call(opts, &out, "getEmergencyModeStartingTime") if err != nil { return *new(uint64), err @@ -361,23 +361,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetEmergencyModeStartingTime( // GetEmergencyModeStartingTime is a free data retrieval call binding the contract method 0x668cdd67. // // Solidity: function getEmergencyModeStartingTime() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerSession) GetEmergencyModeStartingTime() (uint64, error) { - return _WithdrawalDelayer.Contract.GetEmergencyModeStartingTime(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) GetEmergencyModeStartingTime() (uint64, error) { + return _Withdrawaldelayer.Contract.GetEmergencyModeStartingTime(&_Withdrawaldelayer.CallOpts) } // GetEmergencyModeStartingTime is a free data retrieval call binding the contract method 0x668cdd67. // // Solidity: function getEmergencyModeStartingTime() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) GetEmergencyModeStartingTime() (uint64, error) { - return _WithdrawalDelayer.Contract.GetEmergencyModeStartingTime(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) GetEmergencyModeStartingTime() (uint64, error) { + return _Withdrawaldelayer.Contract.GetEmergencyModeStartingTime(&_Withdrawaldelayer.CallOpts) } // GetHermezGovernanceAddress is a free data retrieval call binding the contract method 0x0b21d430. // // Solidity: function getHermezGovernanceAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetHermezGovernanceAddress(opts *bind.CallOpts) (common.Address, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) GetHermezGovernanceAddress(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "getHermezGovernanceAddress") + err := _Withdrawaldelayer.contract.Call(opts, &out, "getHermezGovernanceAddress") if err != nil { return *new(common.Address), err @@ -392,23 +392,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetHermezGovernanceAddress(op // GetHermezGovernanceAddress is a free data retrieval call binding the contract method 0x0b21d430. // // Solidity: function getHermezGovernanceAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerSession) GetHermezGovernanceAddress() (common.Address, error) { - return _WithdrawalDelayer.Contract.GetHermezGovernanceAddress(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) GetHermezGovernanceAddress() (common.Address, error) { + return _Withdrawaldelayer.Contract.GetHermezGovernanceAddress(&_Withdrawaldelayer.CallOpts) } // GetHermezGovernanceAddress is a free data retrieval call binding the contract method 0x0b21d430. // // Solidity: function getHermezGovernanceAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) GetHermezGovernanceAddress() (common.Address, error) { - return _WithdrawalDelayer.Contract.GetHermezGovernanceAddress(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) GetHermezGovernanceAddress() (common.Address, error) { + return _Withdrawaldelayer.Contract.GetHermezGovernanceAddress(&_Withdrawaldelayer.CallOpts) } // GetWithdrawalDelay is a free data retrieval call binding the contract method 0x03160940. // // Solidity: function getWithdrawalDelay() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetWithdrawalDelay(opts *bind.CallOpts) (uint64, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) GetWithdrawalDelay(opts *bind.CallOpts) (uint64, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "getWithdrawalDelay") + err := _Withdrawaldelayer.contract.Call(opts, &out, "getWithdrawalDelay") if err != nil { return *new(uint64), err @@ -423,23 +423,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) GetWithdrawalDelay(opts *bind // GetWithdrawalDelay is a free data retrieval call binding the contract method 0x03160940. // // Solidity: function getWithdrawalDelay() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerSession) GetWithdrawalDelay() (uint64, error) { - return _WithdrawalDelayer.Contract.GetWithdrawalDelay(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) GetWithdrawalDelay() (uint64, error) { + return _Withdrawaldelayer.Contract.GetWithdrawalDelay(&_Withdrawaldelayer.CallOpts) } // GetWithdrawalDelay is a free data retrieval call binding the contract method 0x03160940. // // Solidity: function getWithdrawalDelay() view returns(uint64) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) GetWithdrawalDelay() (uint64, error) { - return _WithdrawalDelayer.Contract.GetWithdrawalDelay(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) GetWithdrawalDelay() (uint64, error) { + return _Withdrawaldelayer.Contract.GetWithdrawalDelay(&_Withdrawaldelayer.CallOpts) } // HermezRollupAddress is a free data retrieval call binding the contract method 0x0fd266d7. // // Solidity: function hermezRollupAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) HermezRollupAddress(opts *bind.CallOpts) (common.Address, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) HermezRollupAddress(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "hermezRollupAddress") + err := _Withdrawaldelayer.contract.Call(opts, &out, "hermezRollupAddress") if err != nil { return *new(common.Address), err @@ -454,23 +454,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) HermezRollupAddress(opts *bin // HermezRollupAddress is a free data retrieval call binding the contract method 0x0fd266d7. // // Solidity: function hermezRollupAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerSession) HermezRollupAddress() (common.Address, error) { - return _WithdrawalDelayer.Contract.HermezRollupAddress(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) HermezRollupAddress() (common.Address, error) { + return _Withdrawaldelayer.Contract.HermezRollupAddress(&_Withdrawaldelayer.CallOpts) } // HermezRollupAddress is a free data retrieval call binding the contract method 0x0fd266d7. // // Solidity: function hermezRollupAddress() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) HermezRollupAddress() (common.Address, error) { - return _WithdrawalDelayer.Contract.HermezRollupAddress(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) HermezRollupAddress() (common.Address, error) { + return _Withdrawaldelayer.Contract.HermezRollupAddress(&_Withdrawaldelayer.CallOpts) } // IsEmergencyMode is a free data retrieval call binding the contract method 0x20a194b8. // // Solidity: function isEmergencyMode() view returns(bool) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) IsEmergencyMode(opts *bind.CallOpts) (bool, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) IsEmergencyMode(opts *bind.CallOpts) (bool, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "isEmergencyMode") + err := _Withdrawaldelayer.contract.Call(opts, &out, "isEmergencyMode") if err != nil { return *new(bool), err @@ -485,23 +485,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) IsEmergencyMode(opts *bind.Ca // IsEmergencyMode is a free data retrieval call binding the contract method 0x20a194b8. // // Solidity: function isEmergencyMode() view returns(bool) -func (_WithdrawalDelayer *WithdrawalDelayerSession) IsEmergencyMode() (bool, error) { - return _WithdrawalDelayer.Contract.IsEmergencyMode(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) IsEmergencyMode() (bool, error) { + return _Withdrawaldelayer.Contract.IsEmergencyMode(&_Withdrawaldelayer.CallOpts) } // IsEmergencyMode is a free data retrieval call binding the contract method 0x20a194b8. // // Solidity: function isEmergencyMode() view returns(bool) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) IsEmergencyMode() (bool, error) { - return _WithdrawalDelayer.Contract.IsEmergencyMode(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) IsEmergencyMode() (bool, error) { + return _Withdrawaldelayer.Contract.IsEmergencyMode(&_Withdrawaldelayer.CallOpts) } // PendingEmergencyCouncil is a free data retrieval call binding the contract method 0x67fa2403. // // Solidity: function pendingEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) PendingEmergencyCouncil(opts *bind.CallOpts) (common.Address, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) PendingEmergencyCouncil(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "pendingEmergencyCouncil") + err := _Withdrawaldelayer.contract.Call(opts, &out, "pendingEmergencyCouncil") if err != nil { return *new(common.Address), err @@ -516,23 +516,23 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) PendingEmergencyCouncil(opts // PendingEmergencyCouncil is a free data retrieval call binding the contract method 0x67fa2403. // // Solidity: function pendingEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerSession) PendingEmergencyCouncil() (common.Address, error) { - return _WithdrawalDelayer.Contract.PendingEmergencyCouncil(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) PendingEmergencyCouncil() (common.Address, error) { + return _Withdrawaldelayer.Contract.PendingEmergencyCouncil(&_Withdrawaldelayer.CallOpts) } // PendingEmergencyCouncil is a free data retrieval call binding the contract method 0x67fa2403. // // Solidity: function pendingEmergencyCouncil() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) PendingEmergencyCouncil() (common.Address, error) { - return _WithdrawalDelayer.Contract.PendingEmergencyCouncil(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) PendingEmergencyCouncil() (common.Address, error) { + return _Withdrawaldelayer.Contract.PendingEmergencyCouncil(&_Withdrawaldelayer.CallOpts) } // PendingGovernance is a free data retrieval call binding the contract method 0xf39c38a0. // // Solidity: function pendingGovernance() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCaller) PendingGovernance(opts *bind.CallOpts) (common.Address, error) { +func (_Withdrawaldelayer *WithdrawaldelayerCaller) PendingGovernance(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _WithdrawalDelayer.contract.Call(opts, &out, "pendingGovernance") + err := _Withdrawaldelayer.contract.Call(opts, &out, "pendingGovernance") if err != nil { return *new(common.Address), err @@ -547,209 +547,209 @@ func (_WithdrawalDelayer *WithdrawalDelayerCaller) PendingGovernance(opts *bind. // PendingGovernance is a free data retrieval call binding the contract method 0xf39c38a0. // // Solidity: function pendingGovernance() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerSession) PendingGovernance() (common.Address, error) { - return _WithdrawalDelayer.Contract.PendingGovernance(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) PendingGovernance() (common.Address, error) { + return _Withdrawaldelayer.Contract.PendingGovernance(&_Withdrawaldelayer.CallOpts) } // PendingGovernance is a free data retrieval call binding the contract method 0xf39c38a0. // // Solidity: function pendingGovernance() view returns(address) -func (_WithdrawalDelayer *WithdrawalDelayerCallerSession) PendingGovernance() (common.Address, error) { - return _WithdrawalDelayer.Contract.PendingGovernance(&_WithdrawalDelayer.CallOpts) +func (_Withdrawaldelayer *WithdrawaldelayerCallerSession) PendingGovernance() (common.Address, error) { + return _Withdrawaldelayer.Contract.PendingGovernance(&_Withdrawaldelayer.CallOpts) } // ChangeWithdrawalDelay is a paid mutator transaction binding the contract method 0x0e670af5. // // Solidity: function changeWithdrawalDelay(uint64 _newWithdrawalDelay) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) ChangeWithdrawalDelay(opts *bind.TransactOpts, _newWithdrawalDelay uint64) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "changeWithdrawalDelay", _newWithdrawalDelay) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) ChangeWithdrawalDelay(opts *bind.TransactOpts, _newWithdrawalDelay uint64) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "changeWithdrawalDelay", _newWithdrawalDelay) } // ChangeWithdrawalDelay is a paid mutator transaction binding the contract method 0x0e670af5. // // Solidity: function changeWithdrawalDelay(uint64 _newWithdrawalDelay) returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) ChangeWithdrawalDelay(_newWithdrawalDelay uint64) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ChangeWithdrawalDelay(&_WithdrawalDelayer.TransactOpts, _newWithdrawalDelay) +func (_Withdrawaldelayer *WithdrawaldelayerSession) ChangeWithdrawalDelay(_newWithdrawalDelay uint64) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ChangeWithdrawalDelay(&_Withdrawaldelayer.TransactOpts, _newWithdrawalDelay) } // ChangeWithdrawalDelay is a paid mutator transaction binding the contract method 0x0e670af5. // // Solidity: function changeWithdrawalDelay(uint64 _newWithdrawalDelay) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) ChangeWithdrawalDelay(_newWithdrawalDelay uint64) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ChangeWithdrawalDelay(&_WithdrawalDelayer.TransactOpts, _newWithdrawalDelay) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) ChangeWithdrawalDelay(_newWithdrawalDelay uint64) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ChangeWithdrawalDelay(&_Withdrawaldelayer.TransactOpts, _newWithdrawalDelay) } // ClaimEmergencyCouncil is a paid mutator transaction binding the contract method 0xca79033f. // // Solidity: function claimEmergencyCouncil() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) ClaimEmergencyCouncil(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "claimEmergencyCouncil") +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) ClaimEmergencyCouncil(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "claimEmergencyCouncil") } // ClaimEmergencyCouncil is a paid mutator transaction binding the contract method 0xca79033f. // // Solidity: function claimEmergencyCouncil() returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) ClaimEmergencyCouncil() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ClaimEmergencyCouncil(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) ClaimEmergencyCouncil() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ClaimEmergencyCouncil(&_Withdrawaldelayer.TransactOpts) } // ClaimEmergencyCouncil is a paid mutator transaction binding the contract method 0xca79033f. // // Solidity: function claimEmergencyCouncil() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) ClaimEmergencyCouncil() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ClaimEmergencyCouncil(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) ClaimEmergencyCouncil() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ClaimEmergencyCouncil(&_Withdrawaldelayer.TransactOpts) } // ClaimGovernance is a paid mutator transaction binding the contract method 0x5d36b190. // // Solidity: function claimGovernance() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) ClaimGovernance(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "claimGovernance") +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) ClaimGovernance(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "claimGovernance") } // ClaimGovernance is a paid mutator transaction binding the contract method 0x5d36b190. // // Solidity: function claimGovernance() returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) ClaimGovernance() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ClaimGovernance(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) ClaimGovernance() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ClaimGovernance(&_Withdrawaldelayer.TransactOpts) } // ClaimGovernance is a paid mutator transaction binding the contract method 0x5d36b190. // // Solidity: function claimGovernance() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) ClaimGovernance() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.ClaimGovernance(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) ClaimGovernance() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.ClaimGovernance(&_Withdrawaldelayer.TransactOpts) } // Deposit is a paid mutator transaction binding the contract method 0xcfc0b641. // // Solidity: function deposit(address _owner, address _token, uint192 _amount) payable returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) Deposit(opts *bind.TransactOpts, _owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "deposit", _owner, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) Deposit(opts *bind.TransactOpts, _owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "deposit", _owner, _token, _amount) } // Deposit is a paid mutator transaction binding the contract method 0xcfc0b641. // // Solidity: function deposit(address _owner, address _token, uint192 _amount) payable returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) Deposit(_owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.Deposit(&_WithdrawalDelayer.TransactOpts, _owner, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerSession) Deposit(_owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.Deposit(&_Withdrawaldelayer.TransactOpts, _owner, _token, _amount) } // Deposit is a paid mutator transaction binding the contract method 0xcfc0b641. // // Solidity: function deposit(address _owner, address _token, uint192 _amount) payable returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) Deposit(_owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.Deposit(&_WithdrawalDelayer.TransactOpts, _owner, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) Deposit(_owner common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.Deposit(&_Withdrawaldelayer.TransactOpts, _owner, _token, _amount) } // EnableEmergencyMode is a paid mutator transaction binding the contract method 0xc5b1c7d0. // // Solidity: function enableEmergencyMode() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) EnableEmergencyMode(opts *bind.TransactOpts) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "enableEmergencyMode") +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) EnableEmergencyMode(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "enableEmergencyMode") } // EnableEmergencyMode is a paid mutator transaction binding the contract method 0xc5b1c7d0. // // Solidity: function enableEmergencyMode() returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) EnableEmergencyMode() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.EnableEmergencyMode(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerSession) EnableEmergencyMode() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.EnableEmergencyMode(&_Withdrawaldelayer.TransactOpts) } // EnableEmergencyMode is a paid mutator transaction binding the contract method 0xc5b1c7d0. // // Solidity: function enableEmergencyMode() returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) EnableEmergencyMode() (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.EnableEmergencyMode(&_WithdrawalDelayer.TransactOpts) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) EnableEmergencyMode() (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.EnableEmergencyMode(&_Withdrawaldelayer.TransactOpts) } // EscapeHatchWithdrawal is a paid mutator transaction binding the contract method 0x7fd6b102. // // Solidity: function escapeHatchWithdrawal(address _to, address _token, uint256 _amount) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) EscapeHatchWithdrawal(opts *bind.TransactOpts, _to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "escapeHatchWithdrawal", _to, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) EscapeHatchWithdrawal(opts *bind.TransactOpts, _to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "escapeHatchWithdrawal", _to, _token, _amount) } // EscapeHatchWithdrawal is a paid mutator transaction binding the contract method 0x7fd6b102. // // Solidity: function escapeHatchWithdrawal(address _to, address _token, uint256 _amount) returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) EscapeHatchWithdrawal(_to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.EscapeHatchWithdrawal(&_WithdrawalDelayer.TransactOpts, _to, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerSession) EscapeHatchWithdrawal(_to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.EscapeHatchWithdrawal(&_Withdrawaldelayer.TransactOpts, _to, _token, _amount) } // EscapeHatchWithdrawal is a paid mutator transaction binding the contract method 0x7fd6b102. // // Solidity: function escapeHatchWithdrawal(address _to, address _token, uint256 _amount) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) EscapeHatchWithdrawal(_to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.EscapeHatchWithdrawal(&_WithdrawalDelayer.TransactOpts, _to, _token, _amount) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) EscapeHatchWithdrawal(_to common.Address, _token common.Address, _amount *big.Int) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.EscapeHatchWithdrawal(&_Withdrawaldelayer.TransactOpts, _to, _token, _amount) } // TransferEmergencyCouncil is a paid mutator transaction binding the contract method 0xdb2a1a81. // // Solidity: function transferEmergencyCouncil(address newEmergencyCouncil) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) TransferEmergencyCouncil(opts *bind.TransactOpts, newEmergencyCouncil common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "transferEmergencyCouncil", newEmergencyCouncil) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) TransferEmergencyCouncil(opts *bind.TransactOpts, newEmergencyCouncil common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "transferEmergencyCouncil", newEmergencyCouncil) } // TransferEmergencyCouncil is a paid mutator transaction binding the contract method 0xdb2a1a81. // // Solidity: function transferEmergencyCouncil(address newEmergencyCouncil) returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) TransferEmergencyCouncil(newEmergencyCouncil common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.TransferEmergencyCouncil(&_WithdrawalDelayer.TransactOpts, newEmergencyCouncil) +func (_Withdrawaldelayer *WithdrawaldelayerSession) TransferEmergencyCouncil(newEmergencyCouncil common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.TransferEmergencyCouncil(&_Withdrawaldelayer.TransactOpts, newEmergencyCouncil) } // TransferEmergencyCouncil is a paid mutator transaction binding the contract method 0xdb2a1a81. // // Solidity: function transferEmergencyCouncil(address newEmergencyCouncil) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) TransferEmergencyCouncil(newEmergencyCouncil common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.TransferEmergencyCouncil(&_WithdrawalDelayer.TransactOpts, newEmergencyCouncil) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) TransferEmergencyCouncil(newEmergencyCouncil common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.TransferEmergencyCouncil(&_Withdrawaldelayer.TransactOpts, newEmergencyCouncil) } // TransferGovernance is a paid mutator transaction binding the contract method 0xd38bfff4. // // Solidity: function transferGovernance(address newGovernance) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) TransferGovernance(opts *bind.TransactOpts, newGovernance common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "transferGovernance", newGovernance) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) TransferGovernance(opts *bind.TransactOpts, newGovernance common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "transferGovernance", newGovernance) } // TransferGovernance is a paid mutator transaction binding the contract method 0xd38bfff4. // // Solidity: function transferGovernance(address newGovernance) returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) TransferGovernance(newGovernance common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.TransferGovernance(&_WithdrawalDelayer.TransactOpts, newGovernance) +func (_Withdrawaldelayer *WithdrawaldelayerSession) TransferGovernance(newGovernance common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.TransferGovernance(&_Withdrawaldelayer.TransactOpts, newGovernance) } // TransferGovernance is a paid mutator transaction binding the contract method 0xd38bfff4. // // Solidity: function transferGovernance(address newGovernance) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) TransferGovernance(newGovernance common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.TransferGovernance(&_WithdrawalDelayer.TransactOpts, newGovernance) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) TransferGovernance(newGovernance common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.TransferGovernance(&_Withdrawaldelayer.TransactOpts, newGovernance) } // Withdrawal is a paid mutator transaction binding the contract method 0xde35f282. // // Solidity: function withdrawal(address _owner, address _token) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactor) Withdrawal(opts *bind.TransactOpts, _owner common.Address, _token common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.contract.Transact(opts, "withdrawal", _owner, _token) +func (_Withdrawaldelayer *WithdrawaldelayerTransactor) Withdrawal(opts *bind.TransactOpts, _owner common.Address, _token common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.contract.Transact(opts, "withdrawal", _owner, _token) } // Withdrawal is a paid mutator transaction binding the contract method 0xde35f282. // // Solidity: function withdrawal(address _owner, address _token) returns() -func (_WithdrawalDelayer *WithdrawalDelayerSession) Withdrawal(_owner common.Address, _token common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.Withdrawal(&_WithdrawalDelayer.TransactOpts, _owner, _token) +func (_Withdrawaldelayer *WithdrawaldelayerSession) Withdrawal(_owner common.Address, _token common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.Withdrawal(&_Withdrawaldelayer.TransactOpts, _owner, _token) } // Withdrawal is a paid mutator transaction binding the contract method 0xde35f282. // // Solidity: function withdrawal(address _owner, address _token) returns() -func (_WithdrawalDelayer *WithdrawalDelayerTransactorSession) Withdrawal(_owner common.Address, _token common.Address) (*types.Transaction, error) { - return _WithdrawalDelayer.Contract.Withdrawal(&_WithdrawalDelayer.TransactOpts, _owner, _token) +func (_Withdrawaldelayer *WithdrawaldelayerTransactorSession) Withdrawal(_owner common.Address, _token common.Address) (*types.Transaction, error) { + return _Withdrawaldelayer.Contract.Withdrawal(&_Withdrawaldelayer.TransactOpts, _owner, _token) } -// WithdrawalDelayerDepositIterator is returned from FilterDeposit and is used to iterate over the raw logs and unpacked data for Deposit events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerDepositIterator struct { - Event *WithdrawalDelayerDeposit // Event containing the contract specifics and raw log +// WithdrawaldelayerDepositIterator is returned from FilterDeposit and is used to iterate over the raw logs and unpacked data for Deposit events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerDepositIterator struct { + Event *WithdrawaldelayerDeposit // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -763,7 +763,7 @@ type WithdrawalDelayerDepositIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerDepositIterator) Next() bool { +func (it *WithdrawaldelayerDepositIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -772,7 +772,7 @@ func (it *WithdrawalDelayerDepositIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerDeposit) + it.Event = new(WithdrawaldelayerDeposit) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -787,7 +787,7 @@ func (it *WithdrawalDelayerDepositIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerDeposit) + it.Event = new(WithdrawaldelayerDeposit) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -803,19 +803,19 @@ func (it *WithdrawalDelayerDepositIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerDepositIterator) Error() error { +func (it *WithdrawaldelayerDepositIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerDepositIterator) Close() error { +func (it *WithdrawaldelayerDepositIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerDeposit represents a Deposit event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerDeposit struct { +// WithdrawaldelayerDeposit represents a Deposit event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerDeposit struct { Owner common.Address Token common.Address Amount *big.Int @@ -826,7 +826,7 @@ type WithdrawalDelayerDeposit struct { // FilterDeposit is a free log retrieval operation binding the contract event 0x41219b99485f78192a5b9b1be28c7d53c3a2bdbe7900ae40c79fae8d9d6108fd. // // Solidity: event Deposit(address indexed owner, address indexed token, uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterDeposit(opts *bind.FilterOpts, owner []common.Address, token []common.Address) (*WithdrawalDelayerDepositIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterDeposit(opts *bind.FilterOpts, owner []common.Address, token []common.Address) (*WithdrawaldelayerDepositIterator, error) { var ownerRule []interface{} for _, ownerItem := range owner { @@ -837,17 +837,17 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterDeposit(opts *bind.Fi tokenRule = append(tokenRule, tokenItem) } - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "Deposit", ownerRule, tokenRule) + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "Deposit", ownerRule, tokenRule) if err != nil { return nil, err } - return &WithdrawalDelayerDepositIterator{contract: _WithdrawalDelayer.contract, event: "Deposit", logs: logs, sub: sub}, nil + return &WithdrawaldelayerDepositIterator{contract: _Withdrawaldelayer.contract, event: "Deposit", logs: logs, sub: sub}, nil } // WatchDeposit is a free log subscription operation binding the contract event 0x41219b99485f78192a5b9b1be28c7d53c3a2bdbe7900ae40c79fae8d9d6108fd. // // Solidity: event Deposit(address indexed owner, address indexed token, uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchDeposit(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerDeposit, owner []common.Address, token []common.Address) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchDeposit(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerDeposit, owner []common.Address, token []common.Address) (event.Subscription, error) { var ownerRule []interface{} for _, ownerItem := range owner { @@ -858,7 +858,7 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchDeposit(opts *bind.Wat tokenRule = append(tokenRule, tokenItem) } - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "Deposit", ownerRule, tokenRule) + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "Deposit", ownerRule, tokenRule) if err != nil { return nil, err } @@ -868,8 +868,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchDeposit(opts *bind.Wat select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerDeposit) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "Deposit", log); err != nil { + event := new(WithdrawaldelayerDeposit) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "Deposit", log); err != nil { return err } event.Raw = log @@ -893,18 +893,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchDeposit(opts *bind.Wat // ParseDeposit is a log parse operation binding the contract event 0x41219b99485f78192a5b9b1be28c7d53c3a2bdbe7900ae40c79fae8d9d6108fd. // // Solidity: event Deposit(address indexed owner, address indexed token, uint192 amount, uint64 depositTimestamp) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseDeposit(log types.Log) (*WithdrawalDelayerDeposit, error) { - event := new(WithdrawalDelayerDeposit) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "Deposit", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseDeposit(log types.Log) (*WithdrawaldelayerDeposit, error) { + event := new(WithdrawaldelayerDeposit) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "Deposit", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerEmergencyModeEnabledIterator is returned from FilterEmergencyModeEnabled and is used to iterate over the raw logs and unpacked data for EmergencyModeEnabled events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerEmergencyModeEnabledIterator struct { - Event *WithdrawalDelayerEmergencyModeEnabled // Event containing the contract specifics and raw log +// WithdrawaldelayerEmergencyModeEnabledIterator is returned from FilterEmergencyModeEnabled and is used to iterate over the raw logs and unpacked data for EmergencyModeEnabled events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerEmergencyModeEnabledIterator struct { + Event *WithdrawaldelayerEmergencyModeEnabled // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -918,7 +918,7 @@ type WithdrawalDelayerEmergencyModeEnabledIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Next() bool { +func (it *WithdrawaldelayerEmergencyModeEnabledIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -927,7 +927,7 @@ func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerEmergencyModeEnabled) + it.Event = new(WithdrawaldelayerEmergencyModeEnabled) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -942,7 +942,7 @@ func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerEmergencyModeEnabled) + it.Event = new(WithdrawaldelayerEmergencyModeEnabled) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -958,40 +958,40 @@ func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Error() error { +func (it *WithdrawaldelayerEmergencyModeEnabledIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerEmergencyModeEnabledIterator) Close() error { +func (it *WithdrawaldelayerEmergencyModeEnabledIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerEmergencyModeEnabled represents a EmergencyModeEnabled event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerEmergencyModeEnabled struct { +// WithdrawaldelayerEmergencyModeEnabled represents a EmergencyModeEnabled event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerEmergencyModeEnabled struct { Raw types.Log // Blockchain specific contextual infos } // FilterEmergencyModeEnabled is a free log retrieval operation binding the contract event 0x2064d51aa5a8bd67928c7675e267e05c67ad5adf7c9098d0a602d01f36fda9c5. // // Solidity: event EmergencyModeEnabled() -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterEmergencyModeEnabled(opts *bind.FilterOpts) (*WithdrawalDelayerEmergencyModeEnabledIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterEmergencyModeEnabled(opts *bind.FilterOpts) (*WithdrawaldelayerEmergencyModeEnabledIterator, error) { - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "EmergencyModeEnabled") + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "EmergencyModeEnabled") if err != nil { return nil, err } - return &WithdrawalDelayerEmergencyModeEnabledIterator{contract: _WithdrawalDelayer.contract, event: "EmergencyModeEnabled", logs: logs, sub: sub}, nil + return &WithdrawaldelayerEmergencyModeEnabledIterator{contract: _Withdrawaldelayer.contract, event: "EmergencyModeEnabled", logs: logs, sub: sub}, nil } // WatchEmergencyModeEnabled is a free log subscription operation binding the contract event 0x2064d51aa5a8bd67928c7675e267e05c67ad5adf7c9098d0a602d01f36fda9c5. // // Solidity: event EmergencyModeEnabled() -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEmergencyModeEnabled(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerEmergencyModeEnabled) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchEmergencyModeEnabled(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerEmergencyModeEnabled) (event.Subscription, error) { - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "EmergencyModeEnabled") + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "EmergencyModeEnabled") if err != nil { return nil, err } @@ -1001,8 +1001,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEmergencyModeEnabled(o select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerEmergencyModeEnabled) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "EmergencyModeEnabled", log); err != nil { + event := new(WithdrawaldelayerEmergencyModeEnabled) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "EmergencyModeEnabled", log); err != nil { return err } event.Raw = log @@ -1026,18 +1026,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEmergencyModeEnabled(o // ParseEmergencyModeEnabled is a log parse operation binding the contract event 0x2064d51aa5a8bd67928c7675e267e05c67ad5adf7c9098d0a602d01f36fda9c5. // // Solidity: event EmergencyModeEnabled() -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseEmergencyModeEnabled(log types.Log) (*WithdrawalDelayerEmergencyModeEnabled, error) { - event := new(WithdrawalDelayerEmergencyModeEnabled) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "EmergencyModeEnabled", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseEmergencyModeEnabled(log types.Log) (*WithdrawaldelayerEmergencyModeEnabled, error) { + event := new(WithdrawaldelayerEmergencyModeEnabled) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "EmergencyModeEnabled", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerEscapeHatchWithdrawalIterator is returned from FilterEscapeHatchWithdrawal and is used to iterate over the raw logs and unpacked data for EscapeHatchWithdrawal events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerEscapeHatchWithdrawalIterator struct { - Event *WithdrawalDelayerEscapeHatchWithdrawal // Event containing the contract specifics and raw log +// WithdrawaldelayerEscapeHatchWithdrawalIterator is returned from FilterEscapeHatchWithdrawal and is used to iterate over the raw logs and unpacked data for EscapeHatchWithdrawal events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerEscapeHatchWithdrawalIterator struct { + Event *WithdrawaldelayerEscapeHatchWithdrawal // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1051,7 +1051,7 @@ type WithdrawalDelayerEscapeHatchWithdrawalIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Next() bool { +func (it *WithdrawaldelayerEscapeHatchWithdrawalIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1060,7 +1060,7 @@ func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerEscapeHatchWithdrawal) + it.Event = new(WithdrawaldelayerEscapeHatchWithdrawal) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1075,7 +1075,7 @@ func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerEscapeHatchWithdrawal) + it.Event = new(WithdrawaldelayerEscapeHatchWithdrawal) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1091,19 +1091,19 @@ func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Error() error { +func (it *WithdrawaldelayerEscapeHatchWithdrawalIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerEscapeHatchWithdrawalIterator) Close() error { +func (it *WithdrawaldelayerEscapeHatchWithdrawalIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerEscapeHatchWithdrawal represents a EscapeHatchWithdrawal event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerEscapeHatchWithdrawal struct { +// WithdrawaldelayerEscapeHatchWithdrawal represents a EscapeHatchWithdrawal event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerEscapeHatchWithdrawal struct { Who common.Address To common.Address Token common.Address @@ -1114,7 +1114,7 @@ type WithdrawalDelayerEscapeHatchWithdrawal struct { // FilterEscapeHatchWithdrawal is a free log retrieval operation binding the contract event 0xde200220117ba95c9a6c4a1a13bb06b0b7be90faa85c8fb4576630119f891693. // // Solidity: event EscapeHatchWithdrawal(address indexed who, address indexed to, address indexed token, uint256 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterEscapeHatchWithdrawal(opts *bind.FilterOpts, who []common.Address, to []common.Address, token []common.Address) (*WithdrawalDelayerEscapeHatchWithdrawalIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterEscapeHatchWithdrawal(opts *bind.FilterOpts, who []common.Address, to []common.Address, token []common.Address) (*WithdrawaldelayerEscapeHatchWithdrawalIterator, error) { var whoRule []interface{} for _, whoItem := range who { @@ -1129,17 +1129,17 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterEscapeHatchWithdrawal tokenRule = append(tokenRule, tokenItem) } - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "EscapeHatchWithdrawal", whoRule, toRule, tokenRule) + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "EscapeHatchWithdrawal", whoRule, toRule, tokenRule) if err != nil { return nil, err } - return &WithdrawalDelayerEscapeHatchWithdrawalIterator{contract: _WithdrawalDelayer.contract, event: "EscapeHatchWithdrawal", logs: logs, sub: sub}, nil + return &WithdrawaldelayerEscapeHatchWithdrawalIterator{contract: _Withdrawaldelayer.contract, event: "EscapeHatchWithdrawal", logs: logs, sub: sub}, nil } // WatchEscapeHatchWithdrawal is a free log subscription operation binding the contract event 0xde200220117ba95c9a6c4a1a13bb06b0b7be90faa85c8fb4576630119f891693. // // Solidity: event EscapeHatchWithdrawal(address indexed who, address indexed to, address indexed token, uint256 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEscapeHatchWithdrawal(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerEscapeHatchWithdrawal, who []common.Address, to []common.Address, token []common.Address) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchEscapeHatchWithdrawal(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerEscapeHatchWithdrawal, who []common.Address, to []common.Address, token []common.Address) (event.Subscription, error) { var whoRule []interface{} for _, whoItem := range who { @@ -1154,7 +1154,7 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEscapeHatchWithdrawal( tokenRule = append(tokenRule, tokenItem) } - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "EscapeHatchWithdrawal", whoRule, toRule, tokenRule) + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "EscapeHatchWithdrawal", whoRule, toRule, tokenRule) if err != nil { return nil, err } @@ -1164,8 +1164,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEscapeHatchWithdrawal( select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerEscapeHatchWithdrawal) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "EscapeHatchWithdrawal", log); err != nil { + event := new(WithdrawaldelayerEscapeHatchWithdrawal) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "EscapeHatchWithdrawal", log); err != nil { return err } event.Raw = log @@ -1189,18 +1189,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchEscapeHatchWithdrawal( // ParseEscapeHatchWithdrawal is a log parse operation binding the contract event 0xde200220117ba95c9a6c4a1a13bb06b0b7be90faa85c8fb4576630119f891693. // // Solidity: event EscapeHatchWithdrawal(address indexed who, address indexed to, address indexed token, uint256 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseEscapeHatchWithdrawal(log types.Log) (*WithdrawalDelayerEscapeHatchWithdrawal, error) { - event := new(WithdrawalDelayerEscapeHatchWithdrawal) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "EscapeHatchWithdrawal", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseEscapeHatchWithdrawal(log types.Log) (*WithdrawaldelayerEscapeHatchWithdrawal, error) { + event := new(WithdrawaldelayerEscapeHatchWithdrawal) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "EscapeHatchWithdrawal", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerInitializeWithdrawalDelayerEventIterator is returned from FilterInitializeWithdrawalDelayerEvent and is used to iterate over the raw logs and unpacked data for InitializeWithdrawalDelayerEvent events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerInitializeWithdrawalDelayerEventIterator struct { - Event *WithdrawalDelayerInitializeWithdrawalDelayerEvent // Event containing the contract specifics and raw log +// WithdrawaldelayerInitializeWithdrawalDelayerEventIterator is returned from FilterInitializeWithdrawalDelayerEvent and is used to iterate over the raw logs and unpacked data for InitializeWithdrawalDelayerEvent events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerInitializeWithdrawalDelayerEventIterator struct { + Event *WithdrawaldelayerInitializeWithdrawalDelayerEvent // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1214,7 +1214,7 @@ type WithdrawalDelayerInitializeWithdrawalDelayerEventIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Next() bool { +func (it *WithdrawaldelayerInitializeWithdrawalDelayerEventIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1223,7 +1223,7 @@ func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Next() bool if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerInitializeWithdrawalDelayerEvent) + it.Event = new(WithdrawaldelayerInitializeWithdrawalDelayerEvent) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1238,7 +1238,7 @@ func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Next() bool // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerInitializeWithdrawalDelayerEvent) + it.Event = new(WithdrawaldelayerInitializeWithdrawalDelayerEvent) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1254,19 +1254,19 @@ func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Next() bool } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Error() error { +func (it *WithdrawaldelayerInitializeWithdrawalDelayerEventIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerInitializeWithdrawalDelayerEventIterator) Close() error { +func (it *WithdrawaldelayerInitializeWithdrawalDelayerEventIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerInitializeWithdrawalDelayerEvent represents a InitializeWithdrawalDelayerEvent event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerInitializeWithdrawalDelayerEvent struct { +// WithdrawaldelayerInitializeWithdrawalDelayerEvent represents a InitializeWithdrawalDelayerEvent event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerInitializeWithdrawalDelayerEvent struct { InitialWithdrawalDelay uint64 InitialHermezGovernanceAddress common.Address InitialEmergencyCouncil common.Address @@ -1276,21 +1276,21 @@ type WithdrawalDelayerInitializeWithdrawalDelayerEvent struct { // FilterInitializeWithdrawalDelayerEvent is a free log retrieval operation binding the contract event 0x8b81dca4c96ae06989fa8aa1baa4ccc05dfb42e0948c7d5b7505b68ccde41eec. // // Solidity: event InitializeWithdrawalDelayerEvent(uint64 initialWithdrawalDelay, address initialHermezGovernanceAddress, address initialEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterInitializeWithdrawalDelayerEvent(opts *bind.FilterOpts) (*WithdrawalDelayerInitializeWithdrawalDelayerEventIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterInitializeWithdrawalDelayerEvent(opts *bind.FilterOpts) (*WithdrawaldelayerInitializeWithdrawalDelayerEventIterator, error) { - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "InitializeWithdrawalDelayerEvent") + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "InitializeWithdrawalDelayerEvent") if err != nil { return nil, err } - return &WithdrawalDelayerInitializeWithdrawalDelayerEventIterator{contract: _WithdrawalDelayer.contract, event: "InitializeWithdrawalDelayerEvent", logs: logs, sub: sub}, nil + return &WithdrawaldelayerInitializeWithdrawalDelayerEventIterator{contract: _Withdrawaldelayer.contract, event: "InitializeWithdrawalDelayerEvent", logs: logs, sub: sub}, nil } // WatchInitializeWithdrawalDelayerEvent is a free log subscription operation binding the contract event 0x8b81dca4c96ae06989fa8aa1baa4ccc05dfb42e0948c7d5b7505b68ccde41eec. // // Solidity: event InitializeWithdrawalDelayerEvent(uint64 initialWithdrawalDelay, address initialHermezGovernanceAddress, address initialEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchInitializeWithdrawalDelayerEvent(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerInitializeWithdrawalDelayerEvent) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchInitializeWithdrawalDelayerEvent(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerInitializeWithdrawalDelayerEvent) (event.Subscription, error) { - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "InitializeWithdrawalDelayerEvent") + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "InitializeWithdrawalDelayerEvent") if err != nil { return nil, err } @@ -1300,8 +1300,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchInitializeWithdrawalDe select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerInitializeWithdrawalDelayerEvent) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "InitializeWithdrawalDelayerEvent", log); err != nil { + event := new(WithdrawaldelayerInitializeWithdrawalDelayerEvent) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "InitializeWithdrawalDelayerEvent", log); err != nil { return err } event.Raw = log @@ -1325,18 +1325,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchInitializeWithdrawalDe // ParseInitializeWithdrawalDelayerEvent is a log parse operation binding the contract event 0x8b81dca4c96ae06989fa8aa1baa4ccc05dfb42e0948c7d5b7505b68ccde41eec. // // Solidity: event InitializeWithdrawalDelayerEvent(uint64 initialWithdrawalDelay, address initialHermezGovernanceAddress, address initialEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseInitializeWithdrawalDelayerEvent(log types.Log) (*WithdrawalDelayerInitializeWithdrawalDelayerEvent, error) { - event := new(WithdrawalDelayerInitializeWithdrawalDelayerEvent) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "InitializeWithdrawalDelayerEvent", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseInitializeWithdrawalDelayerEvent(log types.Log) (*WithdrawaldelayerInitializeWithdrawalDelayerEvent, error) { + event := new(WithdrawaldelayerInitializeWithdrawalDelayerEvent) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "InitializeWithdrawalDelayerEvent", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerNewEmergencyCouncilIterator is returned from FilterNewEmergencyCouncil and is used to iterate over the raw logs and unpacked data for NewEmergencyCouncil events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewEmergencyCouncilIterator struct { - Event *WithdrawalDelayerNewEmergencyCouncil // Event containing the contract specifics and raw log +// WithdrawaldelayerNewEmergencyCouncilIterator is returned from FilterNewEmergencyCouncil and is used to iterate over the raw logs and unpacked data for NewEmergencyCouncil events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewEmergencyCouncilIterator struct { + Event *WithdrawaldelayerNewEmergencyCouncil // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1350,7 +1350,7 @@ type WithdrawalDelayerNewEmergencyCouncilIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Next() bool { +func (it *WithdrawaldelayerNewEmergencyCouncilIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1359,7 +1359,7 @@ func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewEmergencyCouncil) + it.Event = new(WithdrawaldelayerNewEmergencyCouncil) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1374,7 +1374,7 @@ func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewEmergencyCouncil) + it.Event = new(WithdrawaldelayerNewEmergencyCouncil) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1390,19 +1390,19 @@ func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Error() error { +func (it *WithdrawaldelayerNewEmergencyCouncilIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerNewEmergencyCouncilIterator) Close() error { +func (it *WithdrawaldelayerNewEmergencyCouncilIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerNewEmergencyCouncil represents a NewEmergencyCouncil event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewEmergencyCouncil struct { +// WithdrawaldelayerNewEmergencyCouncil represents a NewEmergencyCouncil event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewEmergencyCouncil struct { NewEmergencyCouncil common.Address Raw types.Log // Blockchain specific contextual infos } @@ -1410,21 +1410,21 @@ type WithdrawalDelayerNewEmergencyCouncil struct { // FilterNewEmergencyCouncil is a free log retrieval operation binding the contract event 0xcc267667d474ef34ee2de2d060e7c8b2c7295cefa22e57fd7049e22b5fdb5396. // // Solidity: event NewEmergencyCouncil(address newEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterNewEmergencyCouncil(opts *bind.FilterOpts) (*WithdrawalDelayerNewEmergencyCouncilIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterNewEmergencyCouncil(opts *bind.FilterOpts) (*WithdrawaldelayerNewEmergencyCouncilIterator, error) { - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "NewEmergencyCouncil") + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "NewEmergencyCouncil") if err != nil { return nil, err } - return &WithdrawalDelayerNewEmergencyCouncilIterator{contract: _WithdrawalDelayer.contract, event: "NewEmergencyCouncil", logs: logs, sub: sub}, nil + return &WithdrawaldelayerNewEmergencyCouncilIterator{contract: _Withdrawaldelayer.contract, event: "NewEmergencyCouncil", logs: logs, sub: sub}, nil } // WatchNewEmergencyCouncil is a free log subscription operation binding the contract event 0xcc267667d474ef34ee2de2d060e7c8b2c7295cefa22e57fd7049e22b5fdb5396. // // Solidity: event NewEmergencyCouncil(address newEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewEmergencyCouncil(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerNewEmergencyCouncil) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchNewEmergencyCouncil(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerNewEmergencyCouncil) (event.Subscription, error) { - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "NewEmergencyCouncil") + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "NewEmergencyCouncil") if err != nil { return nil, err } @@ -1434,8 +1434,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewEmergencyCouncil(op select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerNewEmergencyCouncil) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewEmergencyCouncil", log); err != nil { + event := new(WithdrawaldelayerNewEmergencyCouncil) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewEmergencyCouncil", log); err != nil { return err } event.Raw = log @@ -1459,18 +1459,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewEmergencyCouncil(op // ParseNewEmergencyCouncil is a log parse operation binding the contract event 0xcc267667d474ef34ee2de2d060e7c8b2c7295cefa22e57fd7049e22b5fdb5396. // // Solidity: event NewEmergencyCouncil(address newEmergencyCouncil) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseNewEmergencyCouncil(log types.Log) (*WithdrawalDelayerNewEmergencyCouncil, error) { - event := new(WithdrawalDelayerNewEmergencyCouncil) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewEmergencyCouncil", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseNewEmergencyCouncil(log types.Log) (*WithdrawaldelayerNewEmergencyCouncil, error) { + event := new(WithdrawaldelayerNewEmergencyCouncil) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewEmergencyCouncil", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerNewHermezGovernanceAddressIterator is returned from FilterNewHermezGovernanceAddress and is used to iterate over the raw logs and unpacked data for NewHermezGovernanceAddress events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewHermezGovernanceAddressIterator struct { - Event *WithdrawalDelayerNewHermezGovernanceAddress // Event containing the contract specifics and raw log +// WithdrawaldelayerNewHermezGovernanceAddressIterator is returned from FilterNewHermezGovernanceAddress and is used to iterate over the raw logs and unpacked data for NewHermezGovernanceAddress events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewHermezGovernanceAddressIterator struct { + Event *WithdrawaldelayerNewHermezGovernanceAddress // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1484,7 +1484,7 @@ type WithdrawalDelayerNewHermezGovernanceAddressIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Next() bool { +func (it *WithdrawaldelayerNewHermezGovernanceAddressIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1493,7 +1493,7 @@ func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewHermezGovernanceAddress) + it.Event = new(WithdrawaldelayerNewHermezGovernanceAddress) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1508,7 +1508,7 @@ func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewHermezGovernanceAddress) + it.Event = new(WithdrawaldelayerNewHermezGovernanceAddress) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1524,19 +1524,19 @@ func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Error() error { +func (it *WithdrawaldelayerNewHermezGovernanceAddressIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerNewHermezGovernanceAddressIterator) Close() error { +func (it *WithdrawaldelayerNewHermezGovernanceAddressIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerNewHermezGovernanceAddress represents a NewHermezGovernanceAddress event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewHermezGovernanceAddress struct { +// WithdrawaldelayerNewHermezGovernanceAddress represents a NewHermezGovernanceAddress event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewHermezGovernanceAddress struct { NewHermezGovernanceAddress common.Address Raw types.Log // Blockchain specific contextual infos } @@ -1544,21 +1544,21 @@ type WithdrawalDelayerNewHermezGovernanceAddress struct { // FilterNewHermezGovernanceAddress is a free log retrieval operation binding the contract event 0x3bf02437d5cd40067085d9dac2c3cdcbef0a449d98a259a40d9c24380aca81bf. // // Solidity: event NewHermezGovernanceAddress(address newHermezGovernanceAddress) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterNewHermezGovernanceAddress(opts *bind.FilterOpts) (*WithdrawalDelayerNewHermezGovernanceAddressIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterNewHermezGovernanceAddress(opts *bind.FilterOpts) (*WithdrawaldelayerNewHermezGovernanceAddressIterator, error) { - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "NewHermezGovernanceAddress") + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "NewHermezGovernanceAddress") if err != nil { return nil, err } - return &WithdrawalDelayerNewHermezGovernanceAddressIterator{contract: _WithdrawalDelayer.contract, event: "NewHermezGovernanceAddress", logs: logs, sub: sub}, nil + return &WithdrawaldelayerNewHermezGovernanceAddressIterator{contract: _Withdrawaldelayer.contract, event: "NewHermezGovernanceAddress", logs: logs, sub: sub}, nil } // WatchNewHermezGovernanceAddress is a free log subscription operation binding the contract event 0x3bf02437d5cd40067085d9dac2c3cdcbef0a449d98a259a40d9c24380aca81bf. // // Solidity: event NewHermezGovernanceAddress(address newHermezGovernanceAddress) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewHermezGovernanceAddress(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerNewHermezGovernanceAddress) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchNewHermezGovernanceAddress(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerNewHermezGovernanceAddress) (event.Subscription, error) { - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "NewHermezGovernanceAddress") + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "NewHermezGovernanceAddress") if err != nil { return nil, err } @@ -1568,8 +1568,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewHermezGovernanceAdd select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerNewHermezGovernanceAddress) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewHermezGovernanceAddress", log); err != nil { + event := new(WithdrawaldelayerNewHermezGovernanceAddress) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewHermezGovernanceAddress", log); err != nil { return err } event.Raw = log @@ -1593,18 +1593,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewHermezGovernanceAdd // ParseNewHermezGovernanceAddress is a log parse operation binding the contract event 0x3bf02437d5cd40067085d9dac2c3cdcbef0a449d98a259a40d9c24380aca81bf. // // Solidity: event NewHermezGovernanceAddress(address newHermezGovernanceAddress) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseNewHermezGovernanceAddress(log types.Log) (*WithdrawalDelayerNewHermezGovernanceAddress, error) { - event := new(WithdrawalDelayerNewHermezGovernanceAddress) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewHermezGovernanceAddress", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseNewHermezGovernanceAddress(log types.Log) (*WithdrawaldelayerNewHermezGovernanceAddress, error) { + event := new(WithdrawaldelayerNewHermezGovernanceAddress) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewHermezGovernanceAddress", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerNewWithdrawalDelayIterator is returned from FilterNewWithdrawalDelay and is used to iterate over the raw logs and unpacked data for NewWithdrawalDelay events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewWithdrawalDelayIterator struct { - Event *WithdrawalDelayerNewWithdrawalDelay // Event containing the contract specifics and raw log +// WithdrawaldelayerNewWithdrawalDelayIterator is returned from FilterNewWithdrawalDelay and is used to iterate over the raw logs and unpacked data for NewWithdrawalDelay events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewWithdrawalDelayIterator struct { + Event *WithdrawaldelayerNewWithdrawalDelay // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1618,7 +1618,7 @@ type WithdrawalDelayerNewWithdrawalDelayIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Next() bool { +func (it *WithdrawaldelayerNewWithdrawalDelayIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1627,7 +1627,7 @@ func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewWithdrawalDelay) + it.Event = new(WithdrawaldelayerNewWithdrawalDelay) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1642,7 +1642,7 @@ func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerNewWithdrawalDelay) + it.Event = new(WithdrawaldelayerNewWithdrawalDelay) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1658,19 +1658,19 @@ func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Error() error { +func (it *WithdrawaldelayerNewWithdrawalDelayIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerNewWithdrawalDelayIterator) Close() error { +func (it *WithdrawaldelayerNewWithdrawalDelayIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerNewWithdrawalDelay represents a NewWithdrawalDelay event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerNewWithdrawalDelay struct { +// WithdrawaldelayerNewWithdrawalDelay represents a NewWithdrawalDelay event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerNewWithdrawalDelay struct { WithdrawalDelay uint64 Raw types.Log // Blockchain specific contextual infos } @@ -1678,21 +1678,21 @@ type WithdrawalDelayerNewWithdrawalDelay struct { // FilterNewWithdrawalDelay is a free log retrieval operation binding the contract event 0x6b3670ab51e04a9da086741e5fd1eb36ffaf1d661a15330c528e1f3e0c8722d7. // // Solidity: event NewWithdrawalDelay(uint64 withdrawalDelay) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterNewWithdrawalDelay(opts *bind.FilterOpts) (*WithdrawalDelayerNewWithdrawalDelayIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterNewWithdrawalDelay(opts *bind.FilterOpts) (*WithdrawaldelayerNewWithdrawalDelayIterator, error) { - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "NewWithdrawalDelay") + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "NewWithdrawalDelay") if err != nil { return nil, err } - return &WithdrawalDelayerNewWithdrawalDelayIterator{contract: _WithdrawalDelayer.contract, event: "NewWithdrawalDelay", logs: logs, sub: sub}, nil + return &WithdrawaldelayerNewWithdrawalDelayIterator{contract: _Withdrawaldelayer.contract, event: "NewWithdrawalDelay", logs: logs, sub: sub}, nil } // WatchNewWithdrawalDelay is a free log subscription operation binding the contract event 0x6b3670ab51e04a9da086741e5fd1eb36ffaf1d661a15330c528e1f3e0c8722d7. // // Solidity: event NewWithdrawalDelay(uint64 withdrawalDelay) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewWithdrawalDelay(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerNewWithdrawalDelay) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchNewWithdrawalDelay(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerNewWithdrawalDelay) (event.Subscription, error) { - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "NewWithdrawalDelay") + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "NewWithdrawalDelay") if err != nil { return nil, err } @@ -1702,8 +1702,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewWithdrawalDelay(opt select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerNewWithdrawalDelay) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewWithdrawalDelay", log); err != nil { + event := new(WithdrawaldelayerNewWithdrawalDelay) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewWithdrawalDelay", log); err != nil { return err } event.Raw = log @@ -1727,18 +1727,18 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchNewWithdrawalDelay(opt // ParseNewWithdrawalDelay is a log parse operation binding the contract event 0x6b3670ab51e04a9da086741e5fd1eb36ffaf1d661a15330c528e1f3e0c8722d7. // // Solidity: event NewWithdrawalDelay(uint64 withdrawalDelay) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseNewWithdrawalDelay(log types.Log) (*WithdrawalDelayerNewWithdrawalDelay, error) { - event := new(WithdrawalDelayerNewWithdrawalDelay) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "NewWithdrawalDelay", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseNewWithdrawalDelay(log types.Log) (*WithdrawaldelayerNewWithdrawalDelay, error) { + event := new(WithdrawaldelayerNewWithdrawalDelay) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "NewWithdrawalDelay", log); err != nil { return nil, err } event.Raw = log return event, nil } -// WithdrawalDelayerWithdrawIterator is returned from FilterWithdraw and is used to iterate over the raw logs and unpacked data for Withdraw events raised by the WithdrawalDelayer contract. -type WithdrawalDelayerWithdrawIterator struct { - Event *WithdrawalDelayerWithdraw // Event containing the contract specifics and raw log +// WithdrawaldelayerWithdrawIterator is returned from FilterWithdraw and is used to iterate over the raw logs and unpacked data for Withdraw events raised by the Withdrawaldelayer contract. +type WithdrawaldelayerWithdrawIterator struct { + Event *WithdrawaldelayerWithdraw // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -1752,7 +1752,7 @@ type WithdrawalDelayerWithdrawIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *WithdrawalDelayerWithdrawIterator) Next() bool { +func (it *WithdrawaldelayerWithdrawIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -1761,7 +1761,7 @@ func (it *WithdrawalDelayerWithdrawIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerWithdraw) + it.Event = new(WithdrawaldelayerWithdraw) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1776,7 +1776,7 @@ func (it *WithdrawalDelayerWithdrawIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(WithdrawalDelayerWithdraw) + it.Event = new(WithdrawaldelayerWithdraw) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -1792,19 +1792,19 @@ func (it *WithdrawalDelayerWithdrawIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *WithdrawalDelayerWithdrawIterator) Error() error { +func (it *WithdrawaldelayerWithdrawIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *WithdrawalDelayerWithdrawIterator) Close() error { +func (it *WithdrawaldelayerWithdrawIterator) Close() error { it.sub.Unsubscribe() return nil } -// WithdrawalDelayerWithdraw represents a Withdraw event raised by the WithdrawalDelayer contract. -type WithdrawalDelayerWithdraw struct { +// WithdrawaldelayerWithdraw represents a Withdraw event raised by the Withdrawaldelayer contract. +type WithdrawaldelayerWithdraw struct { Token common.Address Owner common.Address Amount *big.Int @@ -1814,7 +1814,7 @@ type WithdrawalDelayerWithdraw struct { // FilterWithdraw is a free log retrieval operation binding the contract event 0x72608e45b52a95a12c2ac7f15ff53f92fc9572c9d84b6e6b5d7f0f7826cf3271. // // Solidity: event Withdraw(address indexed token, address indexed owner, uint192 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterWithdraw(opts *bind.FilterOpts, token []common.Address, owner []common.Address) (*WithdrawalDelayerWithdrawIterator, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) FilterWithdraw(opts *bind.FilterOpts, token []common.Address, owner []common.Address) (*WithdrawaldelayerWithdrawIterator, error) { var tokenRule []interface{} for _, tokenItem := range token { @@ -1825,17 +1825,17 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) FilterWithdraw(opts *bind.F ownerRule = append(ownerRule, ownerItem) } - logs, sub, err := _WithdrawalDelayer.contract.FilterLogs(opts, "Withdraw", tokenRule, ownerRule) + logs, sub, err := _Withdrawaldelayer.contract.FilterLogs(opts, "Withdraw", tokenRule, ownerRule) if err != nil { return nil, err } - return &WithdrawalDelayerWithdrawIterator{contract: _WithdrawalDelayer.contract, event: "Withdraw", logs: logs, sub: sub}, nil + return &WithdrawaldelayerWithdrawIterator{contract: _Withdrawaldelayer.contract, event: "Withdraw", logs: logs, sub: sub}, nil } // WatchWithdraw is a free log subscription operation binding the contract event 0x72608e45b52a95a12c2ac7f15ff53f92fc9572c9d84b6e6b5d7f0f7826cf3271. // // Solidity: event Withdraw(address indexed token, address indexed owner, uint192 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *WithdrawalDelayerWithdraw, token []common.Address, owner []common.Address) (event.Subscription, error) { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) WatchWithdraw(opts *bind.WatchOpts, sink chan<- *WithdrawaldelayerWithdraw, token []common.Address, owner []common.Address) (event.Subscription, error) { var tokenRule []interface{} for _, tokenItem := range token { @@ -1846,7 +1846,7 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchWithdraw(opts *bind.Wa ownerRule = append(ownerRule, ownerItem) } - logs, sub, err := _WithdrawalDelayer.contract.WatchLogs(opts, "Withdraw", tokenRule, ownerRule) + logs, sub, err := _Withdrawaldelayer.contract.WatchLogs(opts, "Withdraw", tokenRule, ownerRule) if err != nil { return nil, err } @@ -1856,8 +1856,8 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchWithdraw(opts *bind.Wa select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(WithdrawalDelayerWithdraw) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "Withdraw", log); err != nil { + event := new(WithdrawaldelayerWithdraw) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "Withdraw", log); err != nil { return err } event.Raw = log @@ -1881,9 +1881,9 @@ func (_WithdrawalDelayer *WithdrawalDelayerFilterer) WatchWithdraw(opts *bind.Wa // ParseWithdraw is a log parse operation binding the contract event 0x72608e45b52a95a12c2ac7f15ff53f92fc9572c9d84b6e6b5d7f0f7826cf3271. // // Solidity: event Withdraw(address indexed token, address indexed owner, uint192 amount) -func (_WithdrawalDelayer *WithdrawalDelayerFilterer) ParseWithdraw(log types.Log) (*WithdrawalDelayerWithdraw, error) { - event := new(WithdrawalDelayerWithdraw) - if err := _WithdrawalDelayer.contract.UnpackLog(event, "Withdraw", log); err != nil { +func (_Withdrawaldelayer *WithdrawaldelayerFilterer) ParseWithdraw(log types.Log) (*WithdrawaldelayerWithdraw, error) { + event := new(WithdrawaldelayerWithdraw) + if err := _Withdrawaldelayer.contract.UnpackLog(event, "Withdraw", log); err != nil { return nil, err } event.Raw = log diff --git a/eth/ethereum.go b/eth/ethereum.go index 32ca045d1..04995368c 100644 --- a/eth/ethereum.go +++ b/eth/ethereum.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" "github.com/hermeznetwork/hermez-node/common" - HEZ "github.com/hermeznetwork/hermez-node/eth/contracts/tokenHEZ" + tokenhez "github.com/hermeznetwork/hermez-node/eth/contracts/tokenhez" "github.com/hermeznetwork/hermez-node/log" "github.com/hermeznetwork/tracerr" ) @@ -263,7 +263,7 @@ func (c *EthereumClient) EthBlockByNumber(ctx context.Context, number int64) (*c func (c *EthereumClient) EthERC20Consts(tokenAddress ethCommon.Address) (*ERC20Consts, error) { // We use the HEZ token smart contract interfacehere because it's an // ERC20, which allows us to access the standard ERC20 constants. - instance, err := HEZ.NewHEZ(tokenAddress, c.client) + instance, err := tokenhez.NewTokenhez(tokenAddress, c.client) if err != nil { return nil, tracerr.Wrap(err) } diff --git a/eth/rollup.go b/eth/rollup.go index 2a54912fe..27d760ed9 100644 --- a/eth/rollup.go +++ b/eth/rollup.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/hermeznetwork/hermez-node/common" - Hermez "github.com/hermeznetwork/hermez-node/eth/contracts/hermez" + hermez "github.com/hermeznetwork/hermez-node/eth/contracts/hermez" "github.com/hermeznetwork/hermez-node/log" "github.com/hermeznetwork/tracerr" "github.com/iden3/go-iden3-crypto/babyjub" @@ -274,7 +274,7 @@ type RollupClient struct { client *EthereumClient chainID *big.Int address ethCommon.Address - hermez *Hermez.Hermez + hermez *hermez.Hermez token *TokenClient contractAbi abi.ABI opts *bind.CallOpts @@ -283,11 +283,11 @@ type RollupClient struct { // NewRollupClient creates a new RollupClient func NewRollupClient(client *EthereumClient, address ethCommon.Address) (*RollupClient, error) { - contractAbi, err := abi.JSON(strings.NewReader(string(Hermez.HermezABI))) + contractAbi, err := abi.JSON(strings.NewReader(string(hermez.HermezABI))) if err != nil { return nil, tracerr.Wrap(err) } - hermez, err := Hermez.NewHermez(address, client.Client()) + hermez, err := hermez.NewHermez(address, client.Client()) if err != nil { return nil, tracerr.Wrap(err) } diff --git a/eth/token.go b/eth/token.go index 7c29aea44..c874c7387 100644 --- a/eth/token.go +++ b/eth/token.go @@ -3,14 +3,14 @@ package eth import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" ethCommon "github.com/ethereum/go-ethereum/common" - HEZ "github.com/hermeznetwork/hermez-node/eth/contracts/tokenHEZ" + tokenhez "github.com/hermeznetwork/hermez-node/eth/contracts/tokenhez" "github.com/hermeznetwork/tracerr" ) // TokenClient is the implementation of the interface to the Hez Token Smart Contract in ethereum. type TokenClient struct { client *EthereumClient - hez *HEZ.HEZ + hez *tokenhez.Tokenhez address ethCommon.Address name string opts *bind.CallOpts @@ -18,7 +18,7 @@ type TokenClient struct { // NewTokenClient creates a new TokenClient func NewTokenClient(client *EthereumClient, address ethCommon.Address) (*TokenClient, error) { - hez, err := HEZ.NewHEZ(address, client.Client()) + hez, err := tokenhez.NewTokenhez(address, client.Client()) if err != nil { return nil, tracerr.Wrap(err) } diff --git a/eth/wdelayer.go b/eth/wdelayer.go index c146c568e..8292af445 100644 --- a/eth/wdelayer.go +++ b/eth/wdelayer.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/hermeznetwork/hermez-node/common" - WithdrawalDelayer "github.com/hermeznetwork/hermez-node/eth/contracts/withdrawalDelayer" + withdrawaldelayer "github.com/hermeznetwork/hermez-node/eth/contracts/withdrawaldelayer" "github.com/hermeznetwork/hermez-node/log" "github.com/hermeznetwork/tracerr" ) @@ -149,18 +149,18 @@ type WDelayerInterface interface { type WDelayerClient struct { client *EthereumClient address ethCommon.Address - wdelayer *WithdrawalDelayer.WithdrawalDelayer + wdelayer *withdrawaldelayer.Withdrawaldelayer contractAbi abi.ABI opts *bind.CallOpts } // NewWDelayerClient creates a new WDelayerClient func NewWDelayerClient(client *EthereumClient, address ethCommon.Address) (*WDelayerClient, error) { - contractAbi, err := abi.JSON(strings.NewReader(string(WithdrawalDelayer.WithdrawalDelayerABI))) + contractAbi, err := abi.JSON(strings.NewReader(string(withdrawaldelayer.WithdrawaldelayerABI))) if err != nil { return nil, tracerr.Wrap(err) } - wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(address, client.Client()) + wdelayer, err := withdrawaldelayer.NewWithdrawaldelayer(address, client.Client()) if err != nil { return nil, tracerr.Wrap(err) } diff --git a/go.mod b/go.mod index cb96a03f8..46b008fab 100644 --- a/go.mod +++ b/go.mod @@ -30,6 +30,7 @@ require ( github.com/stretchr/testify v1.7.0 github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/urfave/cli/v2 v2.3.0 + github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869 go.uber.org/zap v1.16.0 golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 diff --git a/go.sum b/go.sum index 428969ca3..febdfad0a 100644 --- a/go.sum +++ b/go.sum @@ -642,6 +642,7 @@ github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= @@ -832,6 +833,8 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1: github.com/xtaci/kcp-go v5.4.5+incompatible/go.mod h1:bN6vIwHQbfHaHtFpEssmWsN45a+AZwO7eyRCmEIbtvE= github.com/xtaci/lossyconn v0.0.0-20190602105132-8df528c0c9ae/go.mod h1:gXtu8J62kEgmN++bm9BVICuT/e8yiLI2KFobd/TRFsE= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= +github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869 h1:7v7L5lsfw4w8iqBBXETukHo4IPltmD+mWoLRYUmeGN8= +github.com/yourbasic/graph v0.0.0-20210606180040-8ecfec1c2869/go.mod h1:Rfzr+sqaDreiCaoQbFCu3sTXxeFq/9kXRuyOoSlGQHE= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= diff --git a/health/checkers/statedb.go b/health/checkers/statedb.go new file mode 100644 index 000000000..4c2725156 --- /dev/null +++ b/health/checkers/statedb.go @@ -0,0 +1,41 @@ +package checkers + +import ( + "github.com/dimiro1/health" + "github.com/hermeznetwork/hermez-node/db/statedb" +) + +// StateDBChecker struct for state db connection checker +type StateDBChecker struct { + stateDB *statedb.StateDB +} + +// NewStateDBChecker init state db connection checker +func NewStateDBChecker(sdb *statedb.StateDB) StateDBChecker { + return StateDBChecker{ + stateDB: sdb, + } +} + +// Check state db health +func (sdb StateDBChecker) Check() health.Health { + h := health.NewHealth() + + batchNum, err := sdb.stateDB.LastGetCurrentBatch() + if err != nil { + h.Down().AddInfo("error", err.Error()) + return h + } + + root, err := sdb.stateDB.LastMTGetRoot() + if err != nil { + h.Down().AddInfo("error", err.Error()) + return h + } + + h.Up(). + AddInfo("batchNum", batchNum). + AddInfo("root", root.String()) + + return h +} diff --git a/node/node.go b/node/node.go index d9648589f..8ca527d39 100644 --- a/node/node.go +++ b/node/node.go @@ -17,6 +17,7 @@ package node import ( "context" + "encoding/hex" "errors" "fmt" "net" @@ -50,6 +51,7 @@ import ( "github.com/hermeznetwork/hermez-node/txprocessor" "github.com/hermeznetwork/hermez-node/txselector" "github.com/hermeznetwork/tracerr" + "github.com/iden3/go-iden3-crypto/babyjub" "github.com/jmoiron/sqlx" "github.com/russross/meddler" ) @@ -303,21 +305,31 @@ func NewNode(mode Mode, cfg *config.Node, version string) (*Node, error) { cfg.Coordinator.EthClient.Keystore.Password); err != nil { return nil, tracerr.Wrap(err) } + //Swap bjj endianness + decodedBjjPubKey, err := hex.DecodeString(cfg.Coordinator.FeeAccount.BJJ.String()) + if err != nil { + log.Error("Error decoding BJJ public key from config file. Error: ", err.Error()) + return nil, tracerr.Wrap(err) + } + bSwapped := common.SwapEndianness(decodedBjjPubKey) + var bjj babyjub.PublicKeyComp + copy(bjj[:], bSwapped[:]) + auth := &common.AccountCreationAuth{ EthAddr: cfg.Coordinator.FeeAccount.Address, - BJJ: cfg.Coordinator.FeeAccount.BJJ, + BJJ: bjj, } if err := auth.Sign(func(msg []byte) ([]byte, error) { return keyStore.SignHash(feeAccount, msg) }, chainIDU16, cfg.SmartContracts.Rollup); err != nil { return nil, tracerr.Wrap(err) } - coordAccount := &txselector.CoordAccount{ + coordAccount := txselector.CoordAccount{ Addr: cfg.Coordinator.FeeAccount.Address, - BJJ: cfg.Coordinator.FeeAccount.BJJ, + BJJ: bjj, AccountCreationAuth: auth.Signature, } - txSelector, err := txselector.NewTxSelector(coordAccount, + txSelector, err := txselector.NewTxSelector(&coordAccount, cfg.Coordinator.TxSelector.Path, stateDB, l2DB) if err != nil { return nil, tracerr.Wrap(err) @@ -399,6 +411,7 @@ func NewNode(mode Mode, cfg *config.Node, version string) (*Node, error) { EthNoReuseNonce: cfg.Coordinator.EthClient.NoReuseNonce, EthTxResendTimeout: cfg.Coordinator.EthClient.TxResendTimeout.Duration, MaxGasPrice: cfg.Coordinator.EthClient.MaxGasPrice, + MinGasPrice: cfg.Coordinator.EthClient.MinGasPrice, GasPriceIncPerc: cfg.Coordinator.EthClient.GasPriceIncPerc, TxManagerCheckInterval: cfg.Coordinator.EthClient.CheckLoopInterval.Duration, DebugBatchPath: cfg.Coordinator.Debug.BatchPath, @@ -446,6 +459,7 @@ func NewNode(mode Mode, cfg *config.Node, version string) (*Node, error) { server, historyDB, l2DB, + stateDB, ethClient, &cfg.Coordinator.ForgerAddress, ) @@ -560,6 +574,7 @@ func NewAPIServer(mode Mode, cfg *config.APIServer, version string, ethClient *e server, historyDB, l2DB, + nil, ethClient, forgerAddress, ) @@ -616,6 +631,7 @@ func NewNodeAPI( server *gin.Engine, hdb *historydb.HistoryDB, l2db *l2db.L2DB, + stateDB *statedb.StateDB, ethClient *ethclient.Client, forgerAddress *ethCommon.Address, ) (*NodeAPI, error) { @@ -627,6 +643,7 @@ func NewNodeAPI( engine, hdb, l2db, + stateDB, ethClient, forgerAddress, ) diff --git a/test/l2db_test.go b/test/l2db_test.go index 8d2308ad0..30ebae1e8 100644 --- a/test/l2db_test.go +++ b/test/l2db_test.go @@ -5,6 +5,7 @@ import ( ethCommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestGenAuths(t *testing.T) { @@ -14,6 +15,8 @@ func TestGenAuths(t *testing.T) { const nAuths = 5 auths := GenAuths(nAuths, chainID, hermezContractAddr) for _, auth := range auths { - assert.True(t, auth.VerifySignature(chainID, hermezContractAddr)) + isValid, err := auth.VerifySignature(chainID, hermezContractAddr) + require.NoError(t, err) + assert.True(t, isValid) } } diff --git a/test/til/txs.go b/test/til/txs.go index 6f27261f9..52bdf5ddb 100644 --- a/test/til/txs.go +++ b/test/til/txs.go @@ -721,30 +721,36 @@ func (tc *Context) generateKeys(userNames []string) { // account already created continue } - // babyjubjub key - var sk babyjub.PrivateKey - var iBytes [8]byte - binary.LittleEndian.PutUint64(iBytes[:], uint64(i)) - copy(sk[:], iBytes[:]) // only for testing - // eth address - var key ecdsa.PrivateKey - key.D = big.NewInt(int64(i)) // only for testing - key.PublicKey.X, key.PublicKey.Y = ethCrypto.S256().ScalarBaseMult(key.D.Bytes()) - key.Curve = ethCrypto.S256() - addr := ethCrypto.PubkeyToAddress(key.PublicKey) - - u := User{ - Name: userNames[i-1], - BJJ: &sk, - EthSk: &key, - Addr: addr, - Accounts: make(map[common.TokenID]*Account), - } + u := NewUser(i, userNames[i-1]) tc.Users[userNames[i-1]] = &u } } +// NewUser creates a User deriving its keys at the path keyDerivationIndex +func NewUser(keyDerivationIndex int, name string) User { + // babyjubjub key + var sk babyjub.PrivateKey + var iBytes [8]byte + binary.LittleEndian.PutUint64(iBytes[:], uint64(keyDerivationIndex)) + copy(sk[:], iBytes[:]) // only for testing + + // eth address + var key ecdsa.PrivateKey + key.D = big.NewInt(int64(keyDerivationIndex)) // only for testing + key.PublicKey.X, key.PublicKey.Y = ethCrypto.S256().ScalarBaseMult(key.D.Bytes()) + key.Curve = ethCrypto.S256() + addr := ethCrypto.PubkeyToAddress(key.PublicKey) + + return User{ + Name: name, + BJJ: &sk, + EthSk: &key, + Addr: addr, + Accounts: make(map[common.TokenID]*Account), + } +} + // L1TxsToCommonL1Txs converts an array of []til.L1Tx to []common.L1Tx func L1TxsToCommonL1Txs(l1 []L1Tx) []common.L1Tx { var r []common.L1Tx diff --git a/test/zkproof/flows_test.go b/test/zkproof/flows_test.go index 2a6e76fee..ce02c3ceb 100644 --- a/test/zkproof/flows_test.go +++ b/test/zkproof/flows_test.go @@ -2,6 +2,7 @@ package zkproof import ( "io/ioutil" + "math/big" "strconv" "testing" "time" @@ -18,6 +19,7 @@ import ( "github.com/hermeznetwork/hermez-node/test" "github.com/hermeznetwork/hermez-node/test/til" "github.com/hermeznetwork/hermez-node/test/txsets" + "github.com/hermeznetwork/hermez-node/txprocessor" "github.com/hermeznetwork/hermez-node/txselector" "github.com/jmoiron/sqlx" "github.com/stretchr/testify/assert" @@ -91,7 +93,7 @@ func initTxSelector(t *testing.T, chainID uint16, hermezContractAddr ethCommon.A deleteme = append(deleteme, txselDir) // use Til Coord keys for tests compatibility - coordAccount := &txselector.CoordAccount{ + coordAccount := txselector.CoordAccount{ Addr: coordUser.Addr, BJJ: coordUser.BJJ.Public().Compress(), AccountCreationAuth: nil, @@ -106,7 +108,7 @@ func initTxSelector(t *testing.T, chainID uint16, hermezContractAddr ethCommon.A assert.NoError(t, err) coordAccount.AccountCreationAuth = auth.Signature - txsel, err := txselector.NewTxSelector(coordAccount, txselDir, syncStateDB, l2DB) + txsel, err := txselector.NewTxSelector(&coordAccount, txselDir, syncStateDB, l2DB) require.NoError(t, err) test.WipeDB(l2DB.DB()) @@ -375,3 +377,822 @@ func TestZKInputsExitWithFee0(t *testing.T) { txsel.LocalAccountsDB().Close() syncStateDB.Close() } + +// TestZKInputsAtomicTxs checks the zki for a basic flow using atomic txs +func TestZKInputsAtomicTxs(t *testing.T) { + tc := til.NewContext(ChainID, common.RollupConstMaxL1UserTx) + // generate test transactions, the L1CoordinatorTxs generated by Til + // will be ignored at this test, as will be the TxSelector who + // generates them when needed + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, l2DBTxSel, syncStateDB := initTxSelector(t, ChainID, hermezContractAddr, tc.Users["A"]) + + bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB") + require.NoError(t, err) + deleteme = append(deleteme, bbDir) + bb, err := batchbuilder.NewBatchBuilder(bbDir, syncStateDB, 0, 16) + require.NoError(t, err) + + // restart nonces of TilContext, as will be set by generating directly + // the PoolL2Txs for each specific batch with tc.GeneratePoolL2Txs + tc.RestartNonces() + + // add tokens to HistoryDB to avoid breaking FK constrains + addTokens(t, tc, l2DBTxSel.DB()) + + configBatch := &batchbuilder.ConfigBatch{ + TxProcessorConfig: txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 2, // Different from CC + MaxL1Tx: 2, + MaxTx: 3, + ChainID: ChainID, + }, + } + + // loop over the first 6 batches + expectedRoots := []string{ + "0", + "0", + "4699107814499591308646397797397227709064109108834870471069309801839156153817", + "13944326923512084386654700005952881304026772608660229852183663245455287011418", + } + // Process 3 first batches using til + for i := 0; i < 3; i++ { + log.Debugf("block:0 batch:%d", i+1) + var l1UserTxs []common.L1Tx + if blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum != nil { + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum]) + } + // TxSelector select the transactions for the next Batch + coordIdxs, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(txprocConfig, l1UserTxs, nil) + require.NoError(t, err) + // BatchBuilder build Batch + zki, err := bb.BuildBatch(coordIdxs, configBatch, oL1UserTxs, oL1CoordTxs, oL2Txs) + require.NoError(t, err) + assert.Equal(t, expectedRoots[i], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + } + // Manually generate atomic txs + atomicTxA := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + TokenID: 0, + Amount: big.NewInt(100), + Fee: 0, + Nonce: 0, + RqFromIdx: 257, + RqToIdx: 256, + RqTokenID: 0, + RqAmount: big.NewInt(50), + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + RqOffset: 1, + AtomicGroupID: common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}), + } + _, err = common.NewPoolL2Tx(&atomicTxA) + require.NoError(t, err) + aWallet := til.NewUser(1, "A") + hashTxA, err := atomicTxA.HashToSign(ChainID) + require.NoError(t, err) + atomicTxA.Signature = aWallet.BJJ.SignPoseidon(hashTxA).Compress() + atomicTxB := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 256, + TokenID: 0, + Amount: big.NewInt(50), + Fee: 0, + Nonce: 0, + RqFromIdx: 256, + RqToIdx: 257, + RqTokenID: 0, + RqAmount: big.NewInt(100), + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + RqOffset: 7, + AtomicGroupID: common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}), + } + _, err = common.NewPoolL2Tx(&atomicTxB) + require.NoError(t, err) + bWallet := til.NewUser(2, "B") + hashTxB, err := atomicTxB.HashToSign(ChainID) + require.NoError(t, err) + atomicTxB.Signature = bWallet.BJJ.SignPoseidon(hashTxB).Compress() + + // Add txs to DB + require.NoError(t, l2DBTxSel.AddTxTest(&atomicTxA)) + require.NoError(t, l2DBTxSel.AddTxTest(&atomicTxB)) + + // TxSelector select the transactions for the next Batch + coordIdxs, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(txprocConfig, nil, nil) + require.NoError(t, err) + + // BatchBuilder build Batch + zki, err := bb.BuildBatch(coordIdxs, configBatch, oL1UserTxs, oL1CoordTxs, oL2Txs) + require.NoError(t, err) + assert.Equal(t, expectedRoots[3], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) +} + +func TestZKInputsAtomicTxs2(t *testing.T) { + tc := til.NewContext(ChainID, common.RollupConstMaxL1UserTx) + // generate test transactions, the L1CoordinatorTxs generated by Til + // will be ignored at this test, as will be the TxSelector who + // generates them when needed + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, l2DBTxSel, syncStateDB := initTxSelector(t, ChainID, hermezContractAddr, tc.Users["A"]) + + bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB") + require.NoError(t, err) + deleteme = append(deleteme, bbDir) + bb, err := batchbuilder.NewBatchBuilder(bbDir, syncStateDB, 0, 16) + require.NoError(t, err) + + // restart nonces of TilContext, as will be set by generating directly + // the PoolL2Txs for each specific batch with tc.GeneratePoolL2Txs + tc.RestartNonces() + + // add tokens to HistoryDB to avoid breaking FK constrains + addTokens(t, tc, l2DBTxSel.DB()) + + configBatch := &batchbuilder.ConfigBatch{ + TxProcessorConfig: txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 2, + MaxL1Tx: 2, + MaxTx: 3, + ChainID: ChainID, + }, + } + + // loop over the first 6 batches + expectedRoots := []string{ + "0", + "0", + "4699107814499591308646397797397227709064109108834870471069309801839156153817", + "14308891764306680383563176140366979045110288310078804500780349771465245905349", + "10888624449169052621639761533901677350089347579730136443445410532938653329960", + "10888624449169052621639761533901677350089347579730136443445410532938653329960", + "16211152882311374033982856603217667819334355283282393300267321154116196396852", + } + // Process 3 first batches using til (batch 0 to batch 2) + for i := 0; i < 3; i++ { + log.Debugf("block:0 batch:%d", i+1) + var l1UserTxs []common.L1Tx + if blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum != nil { + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum]) + } + // TxSelector select the transactions for the next Batch + coordIdxs, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(txprocConfig, l1UserTxs, nil) + require.NoError(t, err) + // BatchBuilder build Batch + zki, err := bb.BuildBatch(coordIdxs, configBatch, oL1UserTxs, oL1CoordTxs, oL2Txs) + require.NoError(t, err) + assert.Equal(t, expectedRoots[i], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + } + // Batch 3 + // Manually generate atomic txs + // TX 1 + aWallet := til.NewUser(1, "A") + bWallet := til.NewUser(2, "B") + cWallet := til.NewUser(3, "C") + dWallet := til.NewUser(4, "D") + tx1 := common.PoolL2Tx{ + FromIdx: 256, + ToEthAddr: bWallet.Addr, + Amount: big.NewInt(100), + RqOffset: 2, + RqAmount: big.NewInt(50), + RqFromIdx: 257, + RqToEthAddr: aWallet.Addr, + AtomicGroupID: common.AtomicGroupID([32]byte{1}), + } + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(ChainID) + require.NoError(t, err) + tx1.Signature = aWallet.BJJ.SignPoseidon(hashTx1).Compress() + // TX 2 + tx2 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(50), + Nonce: 1, + State: common.PoolL2TxStatePending, + } + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(ChainID) + require.NoError(t, err) + tx2.Signature = aWallet.BJJ.SignPoseidon(hashTx2).Compress() + // TX 3 + tx3 := common.PoolL2Tx{ + FromIdx: 257, + ToEthAddr: aWallet.Addr, + Amount: big.NewInt(50), + RqFromIdx: 256, + RqToEthAddr: bWallet.Addr, + RqAmount: big.NewInt(100), + State: common.PoolL2TxStatePending, + RqOffset: 6, + AtomicGroupID: common.AtomicGroupID([32]byte{1}), + } + _, err = common.NewPoolL2Tx(&tx3) + require.NoError(t, err) + hashTx3, err := tx3.HashToSign(ChainID) + require.NoError(t, err) + tx3.Signature = bWallet.BJJ.SignPoseidon(hashTx3).Compress() + // BatchBuilder build Batch + zki, err := bb.BuildBatch(nil, configBatch, nil, nil, []common.PoolL2Tx{tx1, tx2, tx3}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[3], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 4 + tx4 := common.L1Tx{ + FromEthAddr: common.FFAddr, + FromBJJ: cWallet.BJJ.Public().Compress(), + TokenID: 0, + FromIdx: 0, + ToIdx: 0, + Amount: big.NewInt(0), + DepositAmount: big.NewInt(0), + UserOrigin: false, + Type: common.TxTypeCreateAccountDeposit, + } + tx5 := common.L1Tx{ + FromEthAddr: common.FFAddr, + FromBJJ: dWallet.BJJ.Public().Compress(), + TokenID: 0, + FromIdx: 0, + ToIdx: 0, + Amount: big.NewInt(0), + DepositAmount: big.NewInt(0), + UserOrigin: false, + Type: common.TxTypeCreateAccountDeposit, + } + // BatchBuilder build Batch + zki, err = bb.BuildBatch(nil, configBatch, nil, []common.L1Tx{tx4, tx5}, nil) + require.NoError(t, err) + assert.Equal(t, expectedRoots[4], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 5 (empty) + zki, err = bb.BuildBatch(nil, configBatch, nil, nil, nil) + require.NoError(t, err) + assert.Equal(t, expectedRoots[5], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 6 + // TX 6 + tx6 := common.PoolL2Tx{ + FromIdx: 256, + ToEthAddr: common.FFAddr, + ToBJJ: cWallet.BJJ.Public().Compress(), + Amount: big.NewInt(100), + Nonce: 2, + RqFromIdx: 257, + RqToEthAddr: common.FFAddr, + RqToBJJ: dWallet.BJJ.Public().Compress(), + RqAmount: big.NewInt(50), + RqNonce: 1, + RqOffset: 1, + AtomicGroupID: common.AtomicGroupID([32]byte{2}), + } + _, err = common.NewPoolL2Tx(&tx6) + require.NoError(t, err) + hashTx6, err := tx6.HashToSign(ChainID) + require.NoError(t, err) + tx6.Signature = aWallet.BJJ.SignPoseidon(hashTx6).Compress() + // TX 7 + tx7 := common.PoolL2Tx{ + FromIdx: 257, + ToEthAddr: common.FFAddr, + ToBJJ: dWallet.BJJ.Public().Compress(), + Amount: big.NewInt(50), + Nonce: 1, + RqFromIdx: 256, + RqToEthAddr: common.FFAddr, + RqToBJJ: cWallet.BJJ.Public().Compress(), + RqAmount: big.NewInt(100), + RqNonce: 2, + RqOffset: 7, + AtomicGroupID: common.AtomicGroupID([32]byte{2}), + } + _, err = common.NewPoolL2Tx(&tx7) + require.NoError(t, err) + hashTx7, err := tx7.HashToSign(ChainID) + require.NoError(t, err) + tx7.Signature = bWallet.BJJ.SignPoseidon(hashTx7).Compress() + // BatchBuilder build Batch + zki, err = bb.BuildBatch(nil, configBatch, nil, nil, []common.PoolL2Tx{tx6, tx7}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[6], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) +} + +func TestZKInputsAtomicTxsEdge(t *testing.T) { + tc := til.NewContext(ChainID, common.RollupConstMaxL1UserTx) + // generate test transactions, the L1CoordinatorTxs generated by Til + // will be ignored at this test, as will be the TxSelector who + // generates them when needed + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, l2DBTxSel, syncStateDB := initTxSelector(t, ChainID, hermezContractAddr, tc.Users["A"]) + + bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB") + require.NoError(t, err) + deleteme = append(deleteme, bbDir) + bb, err := batchbuilder.NewBatchBuilder(bbDir, syncStateDB, 0, 16) + require.NoError(t, err) + + // restart nonces of TilContext, as will be set by generating directly + // the PoolL2Txs for each specific batch with tc.GeneratePoolL2Txs + tc.RestartNonces() + + // add tokens to HistoryDB to avoid breaking FK constrains + addTokens(t, tc, l2DBTxSel.DB()) + + configBatch := &batchbuilder.ConfigBatch{ + TxProcessorConfig: txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 2, + MaxL1Tx: 2, + MaxTx: 5, + ChainID: ChainID, + }, + } + + expectedRoots := []string{ + "0", + "0", + "4699107814499591308646397797397227709064109108834870471069309801839156153817", + "8648946464699997298087254217875026532493805010600455501624011406286390714724", + "7684290783592306799291180752833613052466875765217001615178964094222347541153", + "17470597030213466849471229074732312786496599837367040991361767144166199600072", + "9314847606205893808530649466856518575089682244658827420995223242741746163552", + } + + // Process 3 first batches using til (batch 0 to batch 2) + for i := 0; i < 3; i++ { + log.Debugf("block:0 batch:%d", i+1) + var l1UserTxs []common.L1Tx + if blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum != nil { + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum]) + } + // TxSelector select the transactions for the next Batch + coordIdxs, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(txprocConfig, l1UserTxs, nil) + require.NoError(t, err) + // BatchBuilder build Batch + zki, err := bb.BuildBatch(coordIdxs, configBatch, oL1UserTxs, oL1CoordTxs, oL2Txs) + require.NoError(t, err) + assert.Equal(t, expectedRoots[i], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + } + // Batch 3 + // Manually generate atomic txs + // TX 1 + aWallet := til.NewUser(1, "A") + bWallet := til.NewUser(2, "B") + tx1 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(0), + Fee: 126, + RqOffset: 1, + RqAmount: big.NewInt(10), + RqFromIdx: 257, + RqToIdx: 1, + RqFee: 126, + } + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(ChainID) + require.NoError(t, err) + tx1.Signature = aWallet.BJJ.SignPoseidon(hashTx1).Compress() + // TX 2 + tx2 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 1, + Amount: big.NewInt(10), + Fee: 126, + RqOffset: 7, + RqAmount: big.NewInt(0), + RqFromIdx: 256, + RqToIdx: 257, + RqFee: 126, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(ChainID) + require.NoError(t, err) + tx2.Signature = bWallet.BJJ.SignPoseidon(hashTx2).Compress() + // BatchBuilder build Batch + zki, err := bb.BuildBatch([]common.Idx{256}, configBatch, nil, nil, []common.PoolL2Tx{tx1, tx2}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[3], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 4 + // TX3 + tx3 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(20), + Nonce: 1, + Fee: 127, + RqOffset: 3, + RqAmount: big.NewInt(0), + RqFromIdx: 256, + RqToIdx: 257, + RqNonce: 2, + RqFee: 120, + } + _, err = common.NewPoolL2Tx(&tx3) + require.NoError(t, err) + hashTx3, err := tx3.HashToSign(ChainID) + require.NoError(t, err) + tx3.Signature = aWallet.BJJ.SignPoseidon(hashTx3).Compress() + // TX4 + tx4 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 256, + Amount: big.NewInt(0), + Nonce: 1, + Fee: 128, + RqOffset: 1, + RqAmount: big.NewInt(20), + RqFromIdx: 257, + RqToIdx: 256, + RqNonce: 2, + RqFee: 125, + } + _, err = common.NewPoolL2Tx(&tx4) + require.NoError(t, err) + hashTx4, err := tx4.HashToSign(ChainID) + require.NoError(t, err) + tx4.Signature = bWallet.BJJ.SignPoseidon(hashTx4).Compress() + // TX5 + tx5 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 256, + Amount: big.NewInt(20), + Nonce: 2, + Fee: 125, + RqOffset: 7, + RqAmount: big.NewInt(0), + RqFromIdx: 257, + RqToIdx: 256, + RqNonce: 1, + RqFee: 128, + } + _, err = common.NewPoolL2Tx(&tx5) + require.NoError(t, err) + hashTx5, err := tx5.HashToSign(ChainID) + require.NoError(t, err) + tx5.Signature = bWallet.BJJ.SignPoseidon(hashTx5).Compress() + // TX6 + tx6 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(0), + Nonce: 2, + Fee: 120, + RqOffset: 5, + RqAmount: big.NewInt(20), + RqFromIdx: 256, + RqToIdx: 257, + RqNonce: 1, + RqFee: 127, + } + _, err = common.NewPoolL2Tx(&tx6) + require.NoError(t, err) + hashTx6, err := tx6.HashToSign(ChainID) + require.NoError(t, err) + tx6.Signature = aWallet.BJJ.SignPoseidon(hashTx6).Compress() + // BatchBuilder build Batch + zki, err = bb.BuildBatch([]common.Idx{256}, configBatch, nil, nil, []common.PoolL2Tx{tx3, tx4, tx5, tx6}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[4], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 5 + // TX7 + tx7 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 1, + Amount: big.NewInt(10), + Nonce: 3, + Fee: 121, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx7) + require.NoError(t, err) + hashTx7, err := tx7.HashToSign(ChainID) + require.NoError(t, err) + tx7.Signature = aWallet.BJJ.SignPoseidon(hashTx7).Compress() + // TX8 + tx8 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 1, + Amount: big.NewInt(10), + Nonce: 3, + Fee: 122, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx8) + require.NoError(t, err) + hashTx8, err := tx8.HashToSign(ChainID) + require.NoError(t, err) + tx8.Signature = bWallet.BJJ.SignPoseidon(hashTx8).Compress() + // TX9 + tx9 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 1, + Amount: big.NewInt(10), + Nonce: 4, + Fee: 123, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx9) + require.NoError(t, err) + hashTx9, err := tx9.HashToSign(ChainID) + require.NoError(t, err) + tx9.Signature = aWallet.BJJ.SignPoseidon(hashTx9).Compress() + // TX10 + tx10 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 1, + Amount: big.NewInt(10), + Nonce: 4, + Fee: 124, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx10) + require.NoError(t, err) + hashTx10, err := tx10.HashToSign(ChainID) + require.NoError(t, err) + tx10.Signature = bWallet.BJJ.SignPoseidon(hashTx10).Compress() + // TX11 + tx11 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 1, + Amount: big.NewInt(10), + Nonce: 5, + Fee: 125, + RqFromIdx: 256, + RqToIdx: 1, + RqAmount: big.NewInt(10), + RqNonce: 3, + RqFee: 121, + RqOffset: 4, + Type: common.TxTypeExit, + } + _, err = common.NewPoolL2Tx(&tx11) + require.NoError(t, err) + hashTx11, err := tx11.HashToSign(ChainID) + require.NoError(t, err) + tx11.Signature = aWallet.BJJ.SignPoseidon(hashTx11).Compress() + + zki, err = bb.BuildBatch([]common.Idx{256}, configBatch, nil, nil, []common.PoolL2Tx{tx7, tx8, tx9, tx10, tx11}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[5], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + + // Batch 6 + // TX 12 + tx12 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 257, + Amount: big.NewInt(50), + Nonce: 6, + Fee: 130, + RqFromIdx: 257, + RqToIdx: 1, + RqAmount: big.NewInt(50), + RqNonce: 5, + RqOffset: 1, + RqFee: 128, + } + _, err = common.NewPoolL2Tx(&tx12) + require.NoError(t, err) + hashTx12, err := tx12.HashToSign(ChainID) + require.NoError(t, err) + tx12.Signature = aWallet.BJJ.SignPoseidon(hashTx12).Compress() + // TX 13 + tx13 := common.PoolL2Tx{ + FromIdx: 257, + ToIdx: 1, + Amount: big.NewInt(50), + Nonce: 5, + Fee: 128, + RqFromIdx: 256, + RqToIdx: 257, + RqAmount: big.NewInt(50), + RqNonce: 6, + RqOffset: 7, + RqFee: 130, + } + _, err = common.NewPoolL2Tx(&tx13) + require.NoError(t, err) + hashTx13, err := tx13.HashToSign(ChainID) + require.NoError(t, err) + tx13.Signature = bWallet.BJJ.SignPoseidon(hashTx13).Compress() + // BatchBuilder build Batch + zki, err = bb.BuildBatch([]common.Idx{256}, configBatch, nil, nil, []common.PoolL2Tx{tx12, tx13}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[6], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) +} + +func TestZKInputsMaxNumBatch(t *testing.T) { + tc := til.NewContext(ChainID, common.RollupConstMaxL1UserTx) + // generate test transactions, the L1CoordinatorTxs generated by Til + // will be ignored at this test, as will be the TxSelector who + // generates them when needed + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, l2DBTxSel, syncStateDB := initTxSelector(t, ChainID, hermezContractAddr, tc.Users["A"]) + + bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB") + require.NoError(t, err) + deleteme = append(deleteme, bbDir) + bb, err := batchbuilder.NewBatchBuilder(bbDir, syncStateDB, 0, 16) + require.NoError(t, err) + + // restart nonces of TilContext, as will be set by generating directly + // the PoolL2Txs for each specific batch with tc.GeneratePoolL2Txs + tc.RestartNonces() + + // add tokens to HistoryDB to avoid breaking FK constrains + addTokens(t, tc, l2DBTxSel.DB()) + + configBatch := &batchbuilder.ConfigBatch{ + TxProcessorConfig: txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 2, + MaxL1Tx: 2, + MaxTx: 3, + ChainID: ChainID, + }, + } + + // loop over the first 6 batches + expectedRoots := []string{ + "0", + "0", + "4699107814499591308646397797397227709064109108834870471069309801839156153817", + "14294611316400822660176403598744006193014267799947398151388212959007124022702", + "21860840608558568469163210346771935134727995692557954944916248531843343259626", + } + // Process 3 first batches using til (batch 0 to batch 2) + for i := 0; i < 3; i++ { + log.Debugf("block:0 batch:%d", i+1) + var l1UserTxs []common.L1Tx + if blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum != nil { + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[i].Batch.ForgeL1TxsNum]) + } + // TxSelector select the transactions for the next Batch + coordIdxs, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(txprocConfig, l1UserTxs, nil) + require.NoError(t, err) + // BatchBuilder build Batch + zki, err := bb.BuildBatch(coordIdxs, configBatch, oL1UserTxs, oL1CoordTxs, oL2Txs) + require.NoError(t, err) + assert.Equal(t, expectedRoots[i], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + } + aWallet := til.NewUser(1, "A") + bWallet := til.NewUser(2, "B") + cWallet := til.NewUser(3, "C") + // Batch 3 + // Manually generate atomic txs + // Tx 0 + tx0 := common.L1Tx{ + FromEthAddr: common.FFAddr, + FromBJJ: cWallet.BJJ.Public().Compress(), + DepositAmount: big.NewInt(0), + Amount: big.NewInt(0), + UserOrigin: false, + Type: common.TxTypeCreateAccountDeposit, + } + // TX 1 + tx1 := common.PoolL2Tx{ + FromIdx: 256, + ToEthAddr: bWallet.Addr, + Amount: big.NewInt(100), + Fee: 180, + MaxNumBatch: 4, + } + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(ChainID) + require.NoError(t, err) + tx1.Signature = aWallet.BJJ.SignPoseidon(hashTx1).Compress() + // BatchBuilder build Batch + zki, err := bb.BuildBatch([]common.Idx{257}, configBatch, nil, []common.L1Tx{tx0}, []common.PoolL2Tx{tx1}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[3], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) + // Batch 4 + // TX 2 + tx2 := common.PoolL2Tx{ + FromIdx: 257, + ToEthAddr: common.FFAddr, + ToBJJ: cWallet.BJJ.Public().Compress(), + Amount: big.NewInt(55), + Fee: 126, + MaxNumBatch: 21, + } + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(ChainID) + require.NoError(t, err) + tx2.Signature = bWallet.BJJ.SignPoseidon(hashTx2).Compress() + // TX 3 + tx3 := common.PoolL2Tx{ + FromIdx: 258, + ToIdx: 256, + Amount: big.NewInt(30), + Fee: 125, + MaxNumBatch: 9, + } + _, err = common.NewPoolL2Tx(&tx3) + require.NoError(t, err) + hashTx3, err := tx3.HashToSign(ChainID) + require.NoError(t, err) + tx3.Signature = cWallet.BJJ.SignPoseidon(hashTx3).Compress() + // TX 4 + tx4 := common.PoolL2Tx{ + FromIdx: 256, + ToIdx: 1, + Amount: big.NewInt(20), + Nonce: 1, + Fee: 121, + MaxNumBatch: 5, + } + _, err = common.NewPoolL2Tx(&tx4) + require.NoError(t, err) + hashTx4, err := tx4.HashToSign(ChainID) + require.NoError(t, err) + tx4.Signature = aWallet.BJJ.SignPoseidon(hashTx4).Compress() + // BatchBuilder build Batch + zki, err = bb.BuildBatch([]common.Idx{256}, configBatch, nil, nil, []common.PoolL2Tx{tx2, tx3, tx4}) + require.NoError(t, err) + assert.Equal(t, expectedRoots[4], bb.LocalStateDB().MT.Root().BigInt().String()) + sendProofAndCheckResp(t, zki) +} diff --git a/txprocessor/errors.go b/txprocessor/errors.go new file mode 100644 index 000000000..ea3ace242 --- /dev/null +++ b/txprocessor/errors.go @@ -0,0 +1,6 @@ +package txprocessor + +var ( + // ErrInvalidRqOffset RqOffset must be a value between 0 and 7 (both included) + ErrInvalidRqOffset = "RqOffset must be a value between 0 and 7 (both included)" +) diff --git a/txprocessor/txprocessor.go b/txprocessor/txprocessor.go index 8fb696ac3..ff8e8afc2 100644 --- a/txprocessor/txprocessor.go +++ b/txprocessor/txprocessor.go @@ -98,10 +98,10 @@ import ( // TxProcessor represents the TxProcessor object type TxProcessor struct { - s *statedb.StateDB - zki *common.ZKInputs - // i is the current transaction index in the ZKInputs generation (zki) - i int + state *statedb.StateDB + zki *common.ZKInputs + // txIndex is the current transaction index in the ZKInputs generation (zki) + txIndex int // AccumulatedFees contains the accumulated fees for each token (Coord // Idx) in the processed batch AccumulatedFees map[common.Idx]*big.Int @@ -156,23 +156,28 @@ func newErrorNotEnoughBalance(tx common.Tx) error { } // NewTxProcessor returns a new TxProcessor with the given *StateDB & Config -func NewTxProcessor(sdb *statedb.StateDB, config Config) *TxProcessor { +func NewTxProcessor(state *statedb.StateDB, config Config) *TxProcessor { return &TxProcessor{ - s: sdb, - zki: nil, - i: 0, - config: config, + state: state, + zki: nil, + txIndex: 0, + config: config, } } // StateDB returns a pointer to the StateDB of the TxProcessor -func (tp *TxProcessor) StateDB() *statedb.StateDB { - return tp.s +func (txProcessor *TxProcessor) StateDB() *statedb.StateDB { + return txProcessor.state } -func (tp *TxProcessor) resetZKInputs() { - tp.zki = nil - tp.i = 0 // initialize current transaction index in the ZKInputs generation +// AccumulatedCoordFees returns the accumulated fees for each token (coordinator idx) in the processed batch +func (txProcessor *TxProcessor) AccumulatedCoordFees() map[common.Idx]*big.Int { + return txProcessor.AccumulatedFees +} + +func (txProcessor *TxProcessor) resetZKInputs() { + txProcessor.zki = nil + txProcessor.txIndex = 0 // initialize current transaction index in the ZKInputs generation } // ProcessTxs process the given L1Txs & L2Txs applying the needed updates to @@ -184,59 +189,59 @@ func (tp *TxProcessor) resetZKInputs() { // the HistoryDB, and adds Nonce & TokenID to the L2Txs. // And if TypeSynchronizer returns an array of common.Account with all the // created accounts. -func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinatortxs []common.L1Tx, +func (txProcessor *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinatortxs []common.L1Tx, l2txs []common.PoolL2Tx) (ptOut *ProcessTxOutput, err error) { defer func() { if err == nil { - err = tp.s.MakeCheckpoint() + err = txProcessor.state.MakeCheckpoint() } }() var exitTree *merkletree.MerkleTree var createdAccounts []common.Account - if tp.zki != nil { + if txProcessor.zki != nil { return nil, tracerr.Wrap( errors.New("Expected StateDB.zki==nil, something went wrong and it's not empty")) } - defer tp.resetZKInputs() + defer txProcessor.resetZKInputs() - if len(coordIdxs) >= int(tp.config.MaxFeeTx) { + if len(coordIdxs) > int(txProcessor.config.MaxFeeTx) { return nil, tracerr.Wrap( fmt.Errorf("CoordIdxs (%d) length must be smaller than MaxFeeTx (%d)", - len(coordIdxs), tp.config.MaxFeeTx)) + len(coordIdxs), txProcessor.config.MaxFeeTx)) } nTx := len(l1usertxs) + len(l1coordinatortxs) + len(l2txs) - if nTx > int(tp.config.MaxTx) { + if nTx > int(txProcessor.config.MaxTx) { return nil, tracerr.Wrap( fmt.Errorf("L1UserTx + L1CoordinatorTx + L2Tx (%d) can not be bigger than MaxTx (%d)", - nTx, tp.config.MaxTx)) + nTx, txProcessor.config.MaxTx)) } - if len(l1usertxs)+len(l1coordinatortxs) > int(tp.config.MaxL1Tx) { + if len(l1usertxs)+len(l1coordinatortxs) > int(txProcessor.config.MaxL1Tx) { return nil, tracerr.Wrap(fmt.Errorf("L1UserTx + L1CoordinatorTx (%d) can not be bigger than MaxL1Tx (%d)", - len(l1usertxs)+len(l1coordinatortxs), tp.config.MaxTx)) + len(l1usertxs)+len(l1coordinatortxs), txProcessor.config.MaxTx)) } - if tp.s.Type() == statedb.TypeSynchronizer { - tp.updatedAccounts = make(map[common.Idx]*common.Account) + if txProcessor.state.Type() == statedb.TypeSynchronizer { + txProcessor.updatedAccounts = make(map[common.Idx]*common.Account) } exits := make([]processedExit, nTx) - if tp.s.Type() == statedb.TypeBatchBuilder { - tp.zki = common.NewZKInputs(tp.config.ChainID, tp.config.MaxTx, tp.config.MaxL1Tx, - tp.config.MaxFeeTx, tp.config.NLevels, (tp.s.CurrentBatch() + 1).BigInt()) - tp.zki.OldLastIdx = tp.s.CurrentIdx().BigInt() - tp.zki.OldStateRoot = tp.s.MT.Root().BigInt() - tp.zki.Metadata.NewLastIdxRaw = tp.s.CurrentIdx() + if txProcessor.state.Type() == statedb.TypeBatchBuilder { + txProcessor.zki = common.NewZKInputs(txProcessor.config.ChainID, txProcessor.config.MaxTx, txProcessor.config.MaxL1Tx, + txProcessor.config.MaxFeeTx, txProcessor.config.NLevels, (txProcessor.state.CurrentBatch() + 1).BigInt()) + txProcessor.zki.OldLastIdx = txProcessor.state.CurrentIdx().BigInt() + txProcessor.zki.OldStateRoot = txProcessor.state.MT.Root().BigInt() + txProcessor.zki.Metadata.NewLastIdxRaw = txProcessor.state.CurrentIdx() } // TBD if ExitTree is only in memory or stored in disk, for the moment // is only needed in memory - if tp.s.Type() == statedb.TypeSynchronizer || tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || txProcessor.state.Type() == statedb.TypeBatchBuilder { tmpDir, err := ioutil.TempDir("", "hermez-statedb-exittree") if err != nil { return nil, tracerr.Wrap(err) @@ -251,7 +256,7 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat return nil, tracerr.Wrap(err) } defer sto.Close() - exitTree, err = merkletree.NewMerkleTree(sto, tp.s.MT.MaxLevels()) + exitTree, err = merkletree.NewMerkleTree(sto, txProcessor.state.MT.MaxLevels()) if err != nil { return nil, tracerr.Wrap(err) } @@ -260,12 +265,12 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat // Process L1UserTxs for i := 0; i < len(l1usertxs); i++ { // assumption: l1usertx are sorted by L1Tx.Position - exitIdx, exitAccount, newExit, createdAccount, err := tp.ProcessL1Tx(exitTree, + exitIdx, exitAccount, newExit, createdAccount, err := txProcessor.ProcessL1Tx(exitTree, &l1usertxs[i]) if err != nil { return nil, tracerr.Wrap(err) } - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { if createdAccount != nil { createdAccounts = append(createdAccounts, *createdAccount) l1usertxs[i].EffectiveFromIdx = createdAccount.Idx @@ -273,50 +278,50 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat l1usertxs[i].EffectiveFromIdx = l1usertxs[i].FromIdx } } - if tp.zki != nil { + if txProcessor.zki != nil { l1TxData, err := l1usertxs[i].BytesGeneric() if err != nil { return nil, tracerr.Wrap(err) } - tp.zki.Metadata.L1TxsData = append(tp.zki.Metadata.L1TxsData, l1TxData) + txProcessor.zki.Metadata.L1TxsData = append(txProcessor.zki.Metadata.L1TxsData, l1TxData) l1TxDataAvailability, err := - l1usertxs[i].BytesDataAvailability(tp.zki.Metadata.NLevels) + l1usertxs[i].BytesDataAvailability(txProcessor.zki.Metadata.NLevels) if err != nil { return nil, tracerr.Wrap(err) } - tp.zki.Metadata.L1TxsDataAvailability = - append(tp.zki.Metadata.L1TxsDataAvailability, l1TxDataAvailability) + txProcessor.zki.Metadata.L1TxsDataAvailability = + append(txProcessor.zki.Metadata.L1TxsDataAvailability, l1TxDataAvailability) - tp.zki.ISOutIdx[tp.i] = tp.s.CurrentIdx().BigInt() - tp.zki.ISStateRoot[tp.i] = tp.s.MT.Root().BigInt() + txProcessor.zki.ISOutIdx[txProcessor.txIndex] = txProcessor.state.CurrentIdx().BigInt() + txProcessor.zki.ISStateRoot[txProcessor.txIndex] = txProcessor.state.MT.Root().BigInt() if exitIdx == nil { - tp.zki.ISExitRoot[tp.i] = exitTree.Root().BigInt() + txProcessor.zki.ISExitRoot[txProcessor.txIndex] = exitTree.Root().BigInt() } } - if tp.s.Type() == statedb.TypeSynchronizer || tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || txProcessor.state.Type() == statedb.TypeBatchBuilder { if exitIdx != nil && exitTree != nil && exitAccount != nil { - exits[tp.i] = processedExit{ + exits[txProcessor.txIndex] = processedExit{ exit: true, newExit: newExit, idx: *exitIdx, acc: *exitAccount, } } - tp.i++ + txProcessor.txIndex++ } } // Process L1CoordinatorTxs for i := 0; i < len(l1coordinatortxs); i++ { - exitIdx, _, _, createdAccount, err := tp.ProcessL1Tx(exitTree, &l1coordinatortxs[i]) + exitIdx, _, _, createdAccount, err := txProcessor.ProcessL1Tx(exitTree, &l1coordinatortxs[i]) if err != nil { return nil, tracerr.Wrap(err) } if exitIdx != nil { log.Error("Unexpected Exit in L1CoordinatorTx") } - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { if createdAccount != nil { createdAccounts = append(createdAccounts, *createdAccount) l1coordinatortxs[i].EffectiveFromIdx = createdAccount.Idx @@ -324,24 +329,24 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat l1coordinatortxs[i].EffectiveFromIdx = l1coordinatortxs[i].FromIdx } } - if tp.zki != nil { + if txProcessor.zki != nil { l1TxData, err := l1coordinatortxs[i].BytesGeneric() if err != nil { return nil, tracerr.Wrap(err) } - tp.zki.Metadata.L1TxsData = append(tp.zki.Metadata.L1TxsData, l1TxData) + txProcessor.zki.Metadata.L1TxsData = append(txProcessor.zki.Metadata.L1TxsData, l1TxData) l1TxDataAvailability, err := - l1coordinatortxs[i].BytesDataAvailability(tp.zki.Metadata.NLevels) + l1coordinatortxs[i].BytesDataAvailability(txProcessor.zki.Metadata.NLevels) if err != nil { return nil, tracerr.Wrap(err) } - tp.zki.Metadata.L1TxsDataAvailability = - append(tp.zki.Metadata.L1TxsDataAvailability, l1TxDataAvailability) + txProcessor.zki.Metadata.L1TxsDataAvailability = + append(txProcessor.zki.Metadata.L1TxsDataAvailability, l1TxDataAvailability) - tp.zki.ISOutIdx[tp.i] = tp.s.CurrentIdx().BigInt() - tp.zki.ISStateRoot[tp.i] = tp.s.MT.Root().BigInt() - tp.zki.ISExitRoot[tp.i] = exitTree.Root().BigInt() - tp.i++ + txProcessor.zki.ISOutIdx[txProcessor.txIndex] = txProcessor.state.CurrentIdx().BigInt() + txProcessor.zki.ISStateRoot[txProcessor.txIndex] = txProcessor.state.MT.Root().BigInt() + txProcessor.zki.ISExitRoot[txProcessor.txIndex] = exitTree.Root().BigInt() + txProcessor.txIndex++ } } @@ -350,7 +355,7 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat usedCoordTokenIDs := make(map[common.TokenID]bool) var filteredCoordIdxs []common.Idx for i := 0; i < len(coordIdxs); i++ { - accCoord, err := tp.s.GetAccount(coordIdxs[i]) + accCoord, err := txProcessor.state.GetAccount(coordIdxs[i]) if err != nil { return nil, tracerr.Wrap(err) } @@ -361,154 +366,156 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat } coordIdxs = filteredCoordIdxs - tp.AccumulatedFees = make(map[common.Idx]*big.Int) + txProcessor.AccumulatedFees = make(map[common.Idx]*big.Int) for _, idx := range coordIdxs { - tp.AccumulatedFees[idx] = big.NewInt(0) + txProcessor.AccumulatedFees[idx] = big.NewInt(0) } // once L1UserTxs & L1CoordinatorTxs are processed, get TokenIDs of // coordIdxs. In this way, if a coordIdx uses an Idx that is being // created in the current batch, at this point the Idx will be created - coordIdxsMap, err := tp.s.GetTokenIDsFromIdxs(coordIdxs) + coordIdxsMap, err := txProcessor.state.GetTokenIDsFromIdxs(coordIdxs) if err != nil { return nil, tracerr.Wrap(err) } // collectedFees will contain the amount of fee collected for each // TokenID var collectedFees map[common.TokenID]*big.Int - if tp.s.Type() == statedb.TypeSynchronizer || tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || txProcessor.state.Type() == statedb.TypeBatchBuilder { collectedFees = make(map[common.TokenID]*big.Int) for tokenID := range coordIdxsMap { collectedFees[tokenID] = big.NewInt(0) } } - if tp.zki != nil { + if txProcessor.zki != nil { // get the feePlanTokens - feePlanTokens, err := tp.getFeePlanTokens(coordIdxs) + feePlanTokens, err := txProcessor.getFeePlanTokens(coordIdxs) if err != nil { log.Error(err) return nil, tracerr.Wrap(err) } - copy(tp.zki.FeePlanTokens, feePlanTokens) + copy(txProcessor.zki.FeePlanTokens, feePlanTokens) } // Process L2Txs for i := 0; i < len(l2txs); i++ { - exitIdx, exitAccount, newExit, err := tp.ProcessL2Tx(coordIdxsMap, collectedFees, + exitIdx, exitAccount, newExit, err := txProcessor.ProcessL2Tx(coordIdxsMap, collectedFees, exitTree, &l2txs[i]) if err != nil { return nil, tracerr.Wrap(err) } - if tp.zki != nil { - l2TxData, err := l2txs[i].L2Tx().BytesDataAvailability(tp.zki.Metadata.NLevels) + if txProcessor.zki != nil { + l2TxData, err := l2txs[i].L2Tx().BytesDataAvailability(txProcessor.zki.Metadata.NLevels) if err != nil { return nil, tracerr.Wrap(err) } - tp.zki.Metadata.L2TxsData = append(tp.zki.Metadata.L2TxsData, l2TxData) + txProcessor.zki.Metadata.L2TxsData = append(txProcessor.zki.Metadata.L2TxsData, l2TxData) // Intermediate States - if tp.i < nTx-1 { - tp.zki.ISOutIdx[tp.i] = tp.s.CurrentIdx().BigInt() - tp.zki.ISStateRoot[tp.i] = tp.s.MT.Root().BigInt() - tp.zki.ISAccFeeOut[tp.i] = formatAccumulatedFees(collectedFees, tp.zki.FeePlanTokens, coordIdxs) + if txProcessor.txIndex < nTx-1 { + txProcessor.zki.ISOutIdx[txProcessor.txIndex] = txProcessor.state.CurrentIdx().BigInt() + txProcessor.zki.ISStateRoot[txProcessor.txIndex] = txProcessor.state.MT.Root().BigInt() + txProcessor.zki.ISAccFeeOut[txProcessor.txIndex] = formatAccumulatedFees(collectedFees, txProcessor.zki.FeePlanTokens, coordIdxs) if exitIdx == nil { - tp.zki.ISExitRoot[tp.i] = exitTree.Root().BigInt() + txProcessor.zki.ISExitRoot[txProcessor.txIndex] = exitTree.Root().BigInt() } } } - if tp.s.Type() == statedb.TypeSynchronizer || tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || txProcessor.state.Type() == statedb.TypeBatchBuilder { if exitIdx != nil && exitTree != nil && exitAccount != nil { - exits[tp.i] = processedExit{ + exits[txProcessor.txIndex] = processedExit{ exit: true, newExit: newExit, idx: *exitIdx, acc: *exitAccount, } } - tp.i++ + txProcessor.txIndex++ } } - if tp.zki != nil { + if txProcessor.zki != nil { // Fill the empty slots in the ZKInputs remaining after // processing all L1 & L2 txs - txCompressedDataEmpty := common.TxCompressedDataEmpty(tp.config.ChainID) - last := tp.i - 1 - if tp.i == 0 { + txCompressedDataEmpty := common.TxCompressedDataEmpty(txProcessor.config.ChainID) + last := txProcessor.txIndex - 1 + if txProcessor.txIndex == 0 { last = 0 } - for i := last; i < int(tp.config.MaxTx); i++ { - if i < int(tp.config.MaxTx)-1 { - tp.zki.ISOutIdx[i] = tp.s.CurrentIdx().BigInt() - tp.zki.ISStateRoot[i] = tp.s.MT.Root().BigInt() - tp.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees, - tp.zki.FeePlanTokens, coordIdxs) - tp.zki.ISExitRoot[i] = exitTree.Root().BigInt() + for i := last; i < int(txProcessor.config.MaxTx); i++ { + if i < int(txProcessor.config.MaxTx)-1 { + txProcessor.zki.ISOutIdx[i] = txProcessor.state.CurrentIdx().BigInt() + txProcessor.zki.ISStateRoot[i] = txProcessor.state.MT.Root().BigInt() + txProcessor.zki.ISAccFeeOut[i] = formatAccumulatedFees(collectedFees, + txProcessor.zki.FeePlanTokens, coordIdxs) + txProcessor.zki.ISExitRoot[i] = exitTree.Root().BigInt() } - if i >= tp.i { - tp.zki.TxCompressedData[i] = txCompressedDataEmpty + if i >= txProcessor.txIndex { + txProcessor.zki.TxCompressedData[i] = txCompressedDataEmpty } } - isFinalAccFee := formatAccumulatedFees(collectedFees, tp.zki.FeePlanTokens, coordIdxs) - copy(tp.zki.ISFinalAccFee, isFinalAccFee) + isFinalAccFee := formatAccumulatedFees(collectedFees, txProcessor.zki.FeePlanTokens, coordIdxs) + copy(txProcessor.zki.ISFinalAccFee, isFinalAccFee) // before computing the Fees txs, set the ISInitStateRootFee - tp.zki.ISInitStateRootFee = tp.s.MT.Root().BigInt() + txProcessor.zki.ISInitStateRootFee = txProcessor.state.MT.Root().BigInt() } // distribute the AccumulatedFees from the processed L2Txs into the // Coordinator Idxs - iFee := 0 + indexFee := 0 for _, idx := range coordIdxs { - accumulatedFee := tp.AccumulatedFees[idx] + accumulatedFee := txProcessor.AccumulatedFees[idx] // send the fee to the Idx of the Coordinator for the TokenID // (even if the AccumulatedFee==0, as is how the zk circuit // works) - accCoord, err := tp.s.GetAccount(idx) + accCoord, err := txProcessor.state.GetAccount(idx) if err != nil { log.Errorw("Can not distribute accumulated fees to coordinator account: "+ "No coord Idx to receive fee", "idx", idx) return nil, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.TokenID3[iFee] = accCoord.TokenID.BigInt() - tp.zki.Nonce3[iFee] = accCoord.Nonce.BigInt() + if txProcessor.zki != nil { + txProcessor.zki.TokenID3[indexFee] = accCoord.TokenID.BigInt() + txProcessor.zki.Nonce3[indexFee] = accCoord.Nonce.BigInt() coordBJJSign, coordBJJY := babyjub.UnpackSignY(accCoord.BJJ) if coordBJJSign { - tp.zki.Sign3[iFee] = big.NewInt(1) + txProcessor.zki.Sign3[indexFee] = big.NewInt(1) } - tp.zki.Ay3[iFee] = coordBJJY - tp.zki.Balance3[iFee] = accCoord.Balance - tp.zki.EthAddr3[iFee] = common.EthAddrToBigInt(accCoord.EthAddr) + txProcessor.zki.Ay3[indexFee] = coordBJJY + txProcessor.zki.Balance3[indexFee] = accCoord.Balance + txProcessor.zki.EthAddr3[indexFee] = common.EthAddrToBigInt(accCoord.EthAddr) } accCoord.Balance = new(big.Int).Add(accCoord.Balance, accumulatedFee) - pFee, err := tp.updateAccount(idx, accCoord) + pFee, err := txProcessor.updateAccount(idx, accCoord) if err != nil { log.Error(err) return nil, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings3[iFee] = siblingsToZKInputFormat(pFee.Siblings) - tp.zki.ISStateRootFee[iFee] = tp.s.MT.Root().BigInt() + if txProcessor.zki != nil { + txProcessor.zki.Siblings3[indexFee] = siblingsToZKInputFormat(pFee.Siblings) + if indexFee < len(txProcessor.zki.ISStateRootFee) { + txProcessor.zki.ISStateRootFee[indexFee] = txProcessor.state.MT.Root().BigInt() + } } - iFee++ + indexFee++ } - if tp.zki != nil { - for i := len(tp.AccumulatedFees); i < int(tp.config.MaxFeeTx)-1; i++ { - tp.zki.ISStateRootFee[i] = tp.s.MT.Root().BigInt() + if txProcessor.zki != nil { + for i := len(txProcessor.AccumulatedFees); i < int(txProcessor.config.MaxFeeTx)-1; i++ { + txProcessor.zki.ISStateRootFee[i] = txProcessor.state.MT.Root().BigInt() } // add Coord Idx to ZKInputs.FeeTxsData for i := 0; i < len(coordIdxs); i++ { - tp.zki.FeeIdxs[i] = coordIdxs[i].BigInt() + txProcessor.zki.FeeIdxs[i] = coordIdxs[i].BigInt() } } - if tp.s.Type() == statedb.TypeTxSelector { + if txProcessor.state.Type() == statedb.TypeTxSelector { return nil, nil } - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { // once all txs processed (exitTree root frozen), for each Exit, // generate common.ExitInfo data var exitInfos []common.ExitInfo @@ -549,18 +556,18 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat CreatedAccounts: createdAccounts, CoordinatorIdxsMap: coordIdxsMap, CollectedFees: collectedFees, - UpdatedAccounts: tp.updatedAccounts, + UpdatedAccounts: txProcessor.updatedAccounts, }, nil } // compute last ZKInputs parameters - tp.zki.GlobalChainID = big.NewInt(int64(tp.config.ChainID)) - tp.zki.Metadata.NewStateRootRaw = tp.s.MT.Root() - tp.zki.Metadata.NewExitRootRaw = exitTree.Root() + txProcessor.zki.GlobalChainID = big.NewInt(int64(txProcessor.config.ChainID)) + txProcessor.zki.Metadata.NewStateRootRaw = txProcessor.state.MT.Root() + txProcessor.zki.Metadata.NewExitRootRaw = exitTree.Root() // return ZKInputs as the BatchBuilder will return it to forge the Batch return &ProcessTxOutput{ - ZKInputs: tp.zki, + ZKInputs: txProcessor.zki, ExitInfos: nil, CreatedAccounts: nil, CoordinatorIdxsMap: coordIdxsMap, @@ -570,10 +577,10 @@ func (tp *TxProcessor) ProcessTxs(coordIdxs []common.Idx, l1usertxs, l1coordinat // getFeePlanTokens returns an array of *big.Int containing a list of tokenIDs // corresponding to the given CoordIdxs and the processed L2Txs -func (tp *TxProcessor) getFeePlanTokens(coordIdxs []common.Idx) ([]*big.Int, error) { +func (txProcessor *TxProcessor) getFeePlanTokens(coordIdxs []common.Idx) ([]*big.Int, error) { var tBI []*big.Int for i := 0; i < len(coordIdxs); i++ { - acc, err := tp.s.GetAccount(coordIdxs[i]) + acc, err := txProcessor.state.GetAccount(coordIdxs[i]) if err != nil { log.Errorf("could not get account to determine TokenID of CoordIdx %d not found: %s", coordIdxs[i], err.Error()) @@ -591,35 +598,35 @@ func (tp *TxProcessor) getFeePlanTokens(coordIdxs []common.Idx) ([]*big.Int, err // And another *common.Account parameter which contains the created account in // case that has been a new created account and that the StateDB is of type // TypeSynchronizer. -func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L1Tx) (*common.Idx, +func (txProcessor *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L1Tx) (*common.Idx, *common.Account, bool, *common.Account, error) { // ZKInputs - if tp.zki != nil { + if txProcessor.zki != nil { // Txs var err error - tp.zki.TxCompressedData[tp.i], err = tx.TxCompressedData(tp.config.ChainID) + txProcessor.zki.TxCompressedData[txProcessor.txIndex], err = tx.TxCompressedData(txProcessor.config.ChainID) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) } - tp.zki.FromIdx[tp.i] = tx.FromIdx.BigInt() - tp.zki.ToIdx[tp.i] = tx.ToIdx.BigInt() - tp.zki.OnChain[tp.i] = big.NewInt(1) + txProcessor.zki.FromIdx[txProcessor.txIndex] = tx.FromIdx.BigInt() + txProcessor.zki.ToIdx[txProcessor.txIndex] = tx.ToIdx.BigInt() + txProcessor.zki.OnChain[txProcessor.txIndex] = big.NewInt(1) // L1Txs depositAmountF40, err := common.NewFloat40(tx.DepositAmount) if err != nil { return nil, nil, false, nil, tracerr.Wrap(err) } - tp.zki.DepositAmountF[tp.i] = big.NewInt(int64(depositAmountF40)) - tp.zki.FromEthAddr[tp.i] = common.EthAddrToBigInt(tx.FromEthAddr) + txProcessor.zki.DepositAmountF[txProcessor.txIndex] = big.NewInt(int64(depositAmountF40)) + txProcessor.zki.FromEthAddr[txProcessor.txIndex] = common.EthAddrToBigInt(tx.FromEthAddr) if tx.FromBJJ != common.EmptyBJJComp { - tp.zki.FromBJJCompressed[tp.i] = BJJCompressedTo256BigInts(tx.FromBJJ) + txProcessor.zki.FromBJJCompressed[txProcessor.txIndex] = BJJCompressedTo256BigInts(tx.FromBJJ) } // Intermediate States, for all the transactions except for the last one - if tp.i < len(tp.zki.ISOnChain) { // len(tp.zki.ISOnChain) == nTx - tp.zki.ISOnChain[tp.i] = big.NewInt(1) + if txProcessor.txIndex < len(txProcessor.zki.ISOnChain) { // len(txProcessor.zki.ISOnChain) == nTx + txProcessor.zki.ISOnChain[txProcessor.txIndex] = big.NewInt(1) } if tx.Type == common.TxTypeForceTransfer || @@ -633,13 +640,13 @@ func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L if err != nil { return nil, nil, false, nil, tracerr.Wrap(err) } - tp.zki.AmountF[tp.i] = big.NewInt(int64(amountF40)) + txProcessor.zki.AmountF[txProcessor.txIndex] = big.NewInt(int64(amountF40)) } } switch tx.Type { case common.TxTypeForceTransfer: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // go to the MT account of sender and receiver, and update balance // & nonce @@ -647,16 +654,16 @@ func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L // coordIdxsMap is 'nil', as at L1Txs there is no L2 fees. // 0 for the parameter toIdx, as at L1Tx ToIdx can only be 0 in // the Deposit type case. - err := tp.applyTransfer(nil, nil, tx.Tx(), 0) + err := txProcessor.applyTransfer(nil, nil, tx.Tx(), 0) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) } case common.TxTypeCreateAccountDeposit: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // add new account to the MT, update balance of the MT account - err := tp.applyCreateAccount(tx) + err := txProcessor.applyCreateAccount(tx) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) @@ -665,40 +672,40 @@ func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L // which in the case type==TypeSynchronizer will be added to an // array of created accounts that will be returned case common.TxTypeDeposit: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // update balance of the MT account - err := tp.applyDeposit(tx, false) + err := txProcessor.applyDeposit(tx, false) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) } case common.TxTypeDepositTransfer: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // update balance in MT account, update balance & nonce of sender // & receiver - err := tp.applyDeposit(tx, true) + err := txProcessor.applyDeposit(tx, true) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) } case common.TxTypeCreateAccountDepositTransfer: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // add new account to the merkletree, update balance in MT account, // update balance & nonce of sender & receiver - err := tp.applyCreateAccountDepositTransfer(tx) + err := txProcessor.applyCreateAccountDepositTransfer(tx) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) } case common.TxTypeForceExit: - tp.computeEffectiveAmounts(tx) + txProcessor.computeEffectiveAmounts(tx) // execute exit flow // coordIdxsMap is 'nil', as at L1Txs there is no L2 fees - exitAccount, newExit, err := tp.applyExit(nil, nil, exitTree, tx.Tx(), tx.Amount) + exitAccount, newExit, err := txProcessor.applyExit(nil, nil, exitTree, tx.Tx(), tx.Amount) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) @@ -708,11 +715,11 @@ func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L } var createdAccount *common.Account - if tp.s.Type() == statedb.TypeSynchronizer && + if txProcessor.state.Type() == statedb.TypeSynchronizer && (tx.Type == common.TxTypeCreateAccountDeposit || tx.Type == common.TxTypeCreateAccountDepositTransfer) { var err error - createdAccount, err = tp.s.GetAccount(tp.s.CurrentIdx()) + createdAccount, err = txProcessor.state.GetAccount(txProcessor.state.CurrentIdx()) if err != nil { log.Error(err) return nil, nil, false, nil, tracerr.Wrap(err) @@ -726,13 +733,13 @@ func (tp *TxProcessor) ProcessL1Tx(exitTree *merkletree.MerkleTree, tx *common.L // StateDB depending on the transaction Type. It returns the 3 parameters // related to the Exit (in case of): Idx, ExitAccount, boolean determining if // the Exit created a new Leaf in the ExitTree. -func (tp *TxProcessor) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, +func (txProcessor *TxProcessor) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, collectedFees map[common.TokenID]*big.Int, exitTree *merkletree.MerkleTree, tx *common.PoolL2Tx) (*common.Idx, *common.Account, bool, error) { var err error // if tx.ToIdx==0, get toIdx by ToEthAddr or ToBJJ if tx.ToIdx == common.Idx(0) && tx.AuxToIdx == common.Idx(0) { - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { // this in TypeSynchronizer should never be reached log.Error("WARNING: In StateDB with Synchronizer mode L2.ToIdx can't be 0") return nil, nil, false, @@ -740,71 +747,83 @@ func (tp *TxProcessor) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, } // case when tx.Type == common.TxTypeTransferToEthAddr or // common.TxTypeTransferToBJJ: - accSender, err := tp.s.GetAccount(tx.FromIdx) + accSender, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { return nil, nil, false, tracerr.Wrap(err) } - tx.AuxToIdx, err = tp.s.GetIdxByEthAddrBJJ(tx.ToEthAddr, tx.ToBJJ, accSender.TokenID) + tx.AuxToIdx, err = txProcessor.state.GetIdxByEthAddrBJJ(tx.ToEthAddr, tx.ToBJJ, accSender.TokenID) if err != nil { return nil, nil, false, tracerr.Wrap(err) } } // ZKInputs - if tp.zki != nil { + if txProcessor.zki != nil { // Txs - tp.zki.TxCompressedData[tp.i], err = tx.TxCompressedData(tp.config.ChainID) + txProcessor.zki.TxCompressedData[txProcessor.txIndex], err = tx.TxCompressedData(txProcessor.config.ChainID) if err != nil { return nil, nil, false, tracerr.Wrap(err) } - tp.zki.TxCompressedDataV2[tp.i], err = tx.TxCompressedDataV2() + txProcessor.zki.TxCompressedDataV2[txProcessor.txIndex], err = tx.TxCompressedDataV2() if err != nil { return nil, nil, false, tracerr.Wrap(err) } - tp.zki.FromIdx[tp.i] = tx.FromIdx.BigInt() - tp.zki.ToIdx[tp.i] = tx.ToIdx.BigInt() + txProcessor.zki.FromIdx[txProcessor.txIndex] = tx.FromIdx.BigInt() + txProcessor.zki.ToIdx[txProcessor.txIndex] = tx.ToIdx.BigInt() // fill AuxToIdx if needed if tx.ToIdx == 0 { // use toIdx that can have been filled by tx.ToIdx or // if tx.Idx==0 (this case), toIdx is filled by the Idx // from db by ToEthAddr&ToBJJ - tp.zki.AuxToIdx[tp.i] = tx.AuxToIdx.BigInt() + txProcessor.zki.AuxToIdx[txProcessor.txIndex] = tx.AuxToIdx.BigInt() } if tx.ToBJJ != common.EmptyBJJComp { - _, tp.zki.ToBJJAy[tp.i] = babyjub.UnpackSignY(tx.ToBJJ) + _, txProcessor.zki.ToBJJAy[txProcessor.txIndex] = babyjub.UnpackSignY(tx.ToBJJ) } - tp.zki.ToEthAddr[tp.i] = common.EthAddrToBigInt(tx.ToEthAddr) + txProcessor.zki.ToEthAddr[txProcessor.txIndex] = common.EthAddrToBigInt(tx.ToEthAddr) - tp.zki.OnChain[tp.i] = big.NewInt(0) + txProcessor.zki.OnChain[txProcessor.txIndex] = big.NewInt(0) amountF40, err := common.NewFloat40(tx.Amount) if err != nil { return nil, nil, false, tracerr.Wrap(err) } - tp.zki.AmountF[tp.i] = big.NewInt(int64(amountF40)) - tp.zki.NewAccount[tp.i] = big.NewInt(0) + txProcessor.zki.AmountF[txProcessor.txIndex] = big.NewInt(int64(amountF40)) + txProcessor.zki.NewAccount[txProcessor.txIndex] = big.NewInt(0) + txProcessor.zki.MaxNumBatch[txProcessor.txIndex] = big.NewInt(int64(tx.MaxNumBatch)) - // L2Txs - // tp.zki.RqOffset[tp.i] = // TODO Rq once TxSelector is ready - // tp.zki.RqTxCompressedDataV2[tp.i] = // TODO - // tp.zki.RqToEthAddr[tp.i] = common.EthAddrToBigInt(tx.RqToEthAddr) // TODO - // tp.zki.RqToBJJAy[tp.i] = tx.ToBJJ.Y // TODO + // Rq fields: set zki to link the requested tx + if tx.RqOffset != 0 { + if tx.RqOffset > 7 { //nolint:gomnd + return nil, nil, false, tracerr.New(ErrInvalidRqOffset) + } + rqOffset := big.NewInt(int64(tx.RqOffset)) + txProcessor.zki.RqOffset[txProcessor.txIndex] = rqOffset + txProcessor.zki.RqTxCompressedDataV2[txProcessor.txIndex], err = tx.RqTxCompressedDataV2() + if err != nil { + return nil, nil, false, tracerr.Wrap(err) + } + if tx.RqToBJJ != common.EmptyBJJComp { + _, txProcessor.zki.RqToBJJAy[txProcessor.txIndex] = babyjub.UnpackSignY(tx.RqToBJJ) + } + txProcessor.zki.RqToEthAddr[txProcessor.txIndex] = common.EthAddrToBigInt(tx.RqToEthAddr) + } signature, err := tx.Signature.Decompress() if err != nil { log.Error(err) return nil, nil, false, tracerr.Wrap(err) } - tp.zki.S[tp.i] = signature.S - tp.zki.R8x[tp.i] = signature.R8.X - tp.zki.R8y[tp.i] = signature.R8.Y + txProcessor.zki.S[txProcessor.txIndex] = signature.S + txProcessor.zki.R8x[txProcessor.txIndex] = signature.R8.X + txProcessor.zki.R8y[txProcessor.txIndex] = signature.R8.Y } // if StateDB type==TypeSynchronizer, will need to add Nonce - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { // as tType==TypeSynchronizer, always tx.ToIdx!=0 - acc, err := tp.s.GetAccount(tx.FromIdx) + acc, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { log.Errorw("GetAccount", "fromIdx", tx.FromIdx, "err", err) return nil, nil, false, tracerr.Wrap(err) @@ -817,14 +836,14 @@ func (tp *TxProcessor) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, case common.TxTypeTransfer, common.TxTypeTransferToEthAddr, common.TxTypeTransferToBJJ: // go to the MT account of sender and receiver, and update // balance & nonce - err = tp.applyTransfer(coordIdxsMap, collectedFees, tx.Tx(), tx.AuxToIdx) + err = txProcessor.applyTransfer(coordIdxsMap, collectedFees, tx.Tx(), tx.AuxToIdx) if err != nil { log.Error(err) return nil, nil, false, tracerr.Wrap(err) } case common.TxTypeExit: // execute exit flow - exitAccount, newExit, err := tp.applyExit(coordIdxsMap, collectedFees, exitTree, + exitAccount, newExit, err := txProcessor.applyExit(coordIdxsMap, collectedFees, exitTree, tx.Tx(), tx.Amount) if err != nil { log.Error(err) @@ -838,7 +857,7 @@ func (tp *TxProcessor) ProcessL2Tx(coordIdxsMap map[common.TokenID]common.Idx, // applyCreateAccount creates a new account in the account of the depositer, it // stores the deposit value -func (tp *TxProcessor) applyCreateAccount(tx *common.L1Tx) error { +func (txProcessor *TxProcessor) applyCreateAccount(tx *common.L1Tx) error { account := &common.Account{ TokenID: tx.TokenID, Nonce: 0, @@ -847,84 +866,84 @@ func (tp *TxProcessor) applyCreateAccount(tx *common.L1Tx) error { EthAddr: tx.FromEthAddr, } - p, err := tp.createAccount(common.Idx(tp.s.CurrentIdx()+1), account) + p, err := txProcessor.createAccount(common.Idx(txProcessor.state.CurrentIdx()+1), account) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.TokenID1[tp.i] = tx.TokenID.BigInt() - tp.zki.Nonce1[tp.i] = big.NewInt(0) + if txProcessor.zki != nil { + txProcessor.zki.TokenID1[txProcessor.txIndex] = tx.TokenID.BigInt() + txProcessor.zki.Nonce1[txProcessor.txIndex] = big.NewInt(0) fromBJJSign, fromBJJY := babyjub.UnpackSignY(tx.FromBJJ) if fromBJJSign { - tp.zki.Sign1[tp.i] = big.NewInt(1) + txProcessor.zki.Sign1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay1[tp.i] = fromBJJY - tp.zki.Balance1[tp.i] = tx.EffectiveDepositAmount - tp.zki.EthAddr1[tp.i] = common.EthAddrToBigInt(tx.FromEthAddr) - tp.zki.Siblings1[tp.i] = siblingsToZKInputFormat(p.Siblings) + txProcessor.zki.Ay1[txProcessor.txIndex] = fromBJJY + txProcessor.zki.Balance1[txProcessor.txIndex] = tx.EffectiveDepositAmount + txProcessor.zki.EthAddr1[txProcessor.txIndex] = common.EthAddrToBigInt(tx.FromEthAddr) + txProcessor.zki.Siblings1[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 { - tp.zki.IsOld0_1[tp.i] = big.NewInt(1) + txProcessor.zki.IsOld0_1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.OldKey1[tp.i] = p.OldKey.BigInt() - tp.zki.OldValue1[tp.i] = p.OldValue.BigInt() + txProcessor.zki.OldKey1[txProcessor.txIndex] = p.OldKey.BigInt() + txProcessor.zki.OldValue1[txProcessor.txIndex] = p.OldValue.BigInt() - tp.zki.Metadata.NewLastIdxRaw = tp.s.CurrentIdx() + 1 + txProcessor.zki.Metadata.NewLastIdxRaw = txProcessor.state.CurrentIdx() + 1 - tp.zki.AuxFromIdx[tp.i] = common.Idx(tp.s.CurrentIdx() + 1).BigInt() - tp.zki.NewAccount[tp.i] = big.NewInt(1) + txProcessor.zki.AuxFromIdx[txProcessor.txIndex] = common.Idx(txProcessor.state.CurrentIdx() + 1).BigInt() + txProcessor.zki.NewAccount[txProcessor.txIndex] = big.NewInt(1) - if tp.i < len(tp.zki.ISOnChain) { // len(tp.zki.ISOnChain) == nTx + if txProcessor.txIndex < len(txProcessor.zki.ISOnChain) { // len(txProcessor.zki.ISOnChain) == nTx // intermediate states - tp.zki.ISOnChain[tp.i] = big.NewInt(1) + txProcessor.zki.ISOnChain[txProcessor.txIndex] = big.NewInt(1) } } - return tp.s.SetCurrentIdx(tp.s.CurrentIdx() + 1) + return txProcessor.state.SetCurrentIdx(txProcessor.state.CurrentIdx() + 1) } // createAccount is a wrapper over the StateDB.CreateAccount method that also // stores the created account in the updatedAccounts map in case the StateDB is // of TypeSynchronizer -func (tp *TxProcessor) createAccount(idx common.Idx, account *common.Account) ( +func (txProcessor *TxProcessor) createAccount(idx common.Idx, account *common.Account) ( *merkletree.CircomProcessorProof, error) { - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { account.Idx = idx - tp.updatedAccounts[idx] = account + txProcessor.updatedAccounts[idx] = account } - return tp.s.CreateAccount(idx, account) + return txProcessor.state.CreateAccount(idx, account) } // updateAccount is a wrapper over the StateDB.UpdateAccount method that also // stores the updated account in the updatedAccounts map in case the StateDB is // of TypeSynchronizer -func (tp *TxProcessor) updateAccount(idx common.Idx, account *common.Account) ( +func (txProcessor *TxProcessor) updateAccount(idx common.Idx, account *common.Account) ( *merkletree.CircomProcessorProof, error) { - if tp.s.Type() == statedb.TypeSynchronizer { + if txProcessor.state.Type() == statedb.TypeSynchronizer { account.Idx = idx - tp.updatedAccounts[idx] = account + txProcessor.updatedAccounts[idx] = account } - return tp.s.UpdateAccount(idx, account) + return txProcessor.state.UpdateAccount(idx, account) } // applyDeposit updates the balance in the account of the depositer, if // andTransfer parameter is set to true, the method will also apply the // Transfer of the L1Tx/DepositTransfer -func (tp *TxProcessor) applyDeposit(tx *common.L1Tx, transfer bool) error { - accSender, err := tp.s.GetAccount(tx.FromIdx) +func (txProcessor *TxProcessor) applyDeposit(tx *common.L1Tx, transfer bool) error { + accSender, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.TokenID1[tp.i] = accSender.TokenID.BigInt() - tp.zki.Nonce1[tp.i] = accSender.Nonce.BigInt() + if txProcessor.zki != nil { + txProcessor.zki.TokenID1[txProcessor.txIndex] = accSender.TokenID.BigInt() + txProcessor.zki.Nonce1[txProcessor.txIndex] = accSender.Nonce.BigInt() senderBJJSign, senderBJJY := babyjub.UnpackSignY(accSender.BJJ) if senderBJJSign { - tp.zki.Sign1[tp.i] = big.NewInt(1) + txProcessor.zki.Sign1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay1[tp.i] = senderBJJY - tp.zki.Balance1[tp.i] = accSender.Balance - tp.zki.EthAddr1[tp.i] = common.EthAddrToBigInt(accSender.EthAddr) + txProcessor.zki.Ay1[txProcessor.txIndex] = senderBJJY + txProcessor.zki.Balance1[txProcessor.txIndex] = accSender.Balance + txProcessor.zki.EthAddr1[txProcessor.txIndex] = common.EthAddrToBigInt(accSender.EthAddr) } // add the deposit to the sender @@ -936,12 +955,12 @@ func (tp *TxProcessor) applyDeposit(tx *common.L1Tx, transfer bool) error { } // update sender account in localStateDB - p, err := tp.updateAccount(tx.FromIdx, accSender) + p, err := txProcessor.updateAccount(tx.FromIdx, accSender) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings1[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings1[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) // IsOld0_1, OldKey1, OldValue1 not needed as this is not an insert } @@ -951,34 +970,34 @@ func (tp *TxProcessor) applyDeposit(tx *common.L1Tx, transfer bool) error { if tx.ToIdx == tx.FromIdx { accReceiver = accSender } else { - accReceiver, err = tp.s.GetAccount(tx.ToIdx) + accReceiver, err = txProcessor.state.GetAccount(tx.ToIdx) if err != nil { return tracerr.Wrap(err) } } - if tp.zki != nil { - tp.zki.TokenID2[tp.i] = accReceiver.TokenID.BigInt() - tp.zki.Nonce2[tp.i] = accReceiver.Nonce.BigInt() + if txProcessor.zki != nil { + txProcessor.zki.TokenID2[txProcessor.txIndex] = accReceiver.TokenID.BigInt() + txProcessor.zki.Nonce2[txProcessor.txIndex] = accReceiver.Nonce.BigInt() receiverBJJSign, receiverBJJY := babyjub.UnpackSignY(accReceiver.BJJ) if receiverBJJSign { - tp.zki.Sign2[tp.i] = big.NewInt(1) + txProcessor.zki.Sign2[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay2[tp.i] = receiverBJJY - tp.zki.Balance2[tp.i] = accReceiver.Balance - tp.zki.EthAddr2[tp.i] = common.EthAddrToBigInt(accReceiver.EthAddr) + txProcessor.zki.Ay2[txProcessor.txIndex] = receiverBJJY + txProcessor.zki.Balance2[txProcessor.txIndex] = accReceiver.Balance + txProcessor.zki.EthAddr2[txProcessor.txIndex] = common.EthAddrToBigInt(accReceiver.EthAddr) } // add amount to the receiver accReceiver.Balance = new(big.Int).Add(accReceiver.Balance, tx.EffectiveAmount) // update receiver account in localStateDB - p, err := tp.updateAccount(tx.ToIdx, accReceiver) + p, err := txProcessor.updateAccount(tx.ToIdx, accReceiver) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings2[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings2[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) // IsOld0_2, OldKey2, OldValue2 not needed as this is not an insert } } @@ -992,29 +1011,29 @@ func (tp *TxProcessor) applyDeposit(tx *common.L1Tx, transfer bool) error { // tx.ToIdx==0, then toIdx!=0, and will be used the toIdx parameter as Idx of // the receiver. This parameter is used when the tx.ToIdx is not specified and // the real ToIdx is found trhrough the ToEthAddr or ToBJJ. -func (tp *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, +func (txProcessor *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, collectedFees map[common.TokenID]*big.Int, tx common.Tx, auxToIdx common.Idx) error { if auxToIdx == common.Idx(0) { auxToIdx = tx.ToIdx } // get sender and receiver accounts from localStateDB - accSender, err := tp.s.GetAccount(tx.FromIdx) + accSender, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { log.Error(err) return tracerr.Wrap(err) } - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State1 before updating the Sender leaf - tp.zki.TokenID1[tp.i] = accSender.TokenID.BigInt() - tp.zki.Nonce1[tp.i] = accSender.Nonce.BigInt() + txProcessor.zki.TokenID1[txProcessor.txIndex] = accSender.TokenID.BigInt() + txProcessor.zki.Nonce1[txProcessor.txIndex] = accSender.Nonce.BigInt() senderBJJSign, senderBJJY := babyjub.UnpackSignY(accSender.BJJ) if senderBJJSign { - tp.zki.Sign1[tp.i] = big.NewInt(1) + txProcessor.zki.Sign1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay1[tp.i] = senderBJJY - tp.zki.Balance1[tp.i] = accSender.Balance - tp.zki.EthAddr1[tp.i] = common.EthAddrToBigInt(accSender.EthAddr) + txProcessor.zki.Ay1[txProcessor.txIndex] = senderBJJY + txProcessor.zki.Balance1[txProcessor.txIndex] = accSender.Balance + txProcessor.zki.EthAddr1[txProcessor.txIndex] = common.EthAddrToBigInt(accSender.EthAddr) } if !tx.IsL1 { // L2 // increment nonce @@ -1032,18 +1051,22 @@ func (tp *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, } if _, ok := coordIdxsMap[accSender.TokenID]; ok { - accCoord, err := tp.s.GetAccount(coordIdxsMap[accSender.TokenID]) + accCoord, err := txProcessor.state.GetAccount(coordIdxsMap[accSender.TokenID]) if err != nil { return tracerr.Wrap( fmt.Errorf("Can not use CoordIdx that does not exist in the tree. TokenID: %d, CoordIdx: %d", accSender.TokenID, coordIdxsMap[accSender.TokenID])) } // accumulate the fee for the Coord account - accumulated := tp.AccumulatedFees[accCoord.Idx] + accumulated, ok := txProcessor.AccumulatedFees[accCoord.Idx] + if !ok { + accumulated = big.NewInt(0) + txProcessor.AccumulatedFees[accCoord.Idx] = accumulated + } accumulated.Add(accumulated, fee) - if tp.s.Type() == statedb.TypeSynchronizer || - tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || + txProcessor.state.Type() == statedb.TypeBatchBuilder { collected := collectedFees[accCoord.TokenID] collected.Add(collected, fee) } @@ -1058,13 +1081,13 @@ func (tp *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, } // update sender account in localStateDB - pSender, err := tp.updateAccount(tx.FromIdx, accSender) + pSender, err := txProcessor.updateAccount(tx.FromIdx, accSender) if err != nil { log.Error(err) return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings1[tp.i] = siblingsToZKInputFormat(pSender.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings1[txProcessor.txIndex] = siblingsToZKInputFormat(pSender.Siblings) } var accReceiver *common.Account @@ -1074,35 +1097,35 @@ func (tp *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, // updated yet accReceiver = accSender } else { - accReceiver, err = tp.s.GetAccount(auxToIdx) + accReceiver, err = txProcessor.state.GetAccount(auxToIdx) if err != nil { log.Error(err, auxToIdx) return tracerr.Wrap(err) } } - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State2 before updating the Receiver leaf - tp.zki.TokenID2[tp.i] = accReceiver.TokenID.BigInt() - tp.zki.Nonce2[tp.i] = accReceiver.Nonce.BigInt() + txProcessor.zki.TokenID2[txProcessor.txIndex] = accReceiver.TokenID.BigInt() + txProcessor.zki.Nonce2[txProcessor.txIndex] = accReceiver.Nonce.BigInt() receiverBJJSign, receiverBJJY := babyjub.UnpackSignY(accReceiver.BJJ) if receiverBJJSign { - tp.zki.Sign2[tp.i] = big.NewInt(1) + txProcessor.zki.Sign2[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay2[tp.i] = receiverBJJY - tp.zki.Balance2[tp.i] = accReceiver.Balance - tp.zki.EthAddr2[tp.i] = common.EthAddrToBigInt(accReceiver.EthAddr) + txProcessor.zki.Ay2[txProcessor.txIndex] = receiverBJJY + txProcessor.zki.Balance2[txProcessor.txIndex] = accReceiver.Balance + txProcessor.zki.EthAddr2[txProcessor.txIndex] = common.EthAddrToBigInt(accReceiver.EthAddr) } // add amount-feeAmount to the receiver accReceiver.Balance = new(big.Int).Add(accReceiver.Balance, tx.Amount) // update receiver account in localStateDB - pReceiver, err := tp.updateAccount(auxToIdx, accReceiver) + pReceiver, err := txProcessor.updateAccount(auxToIdx, accReceiver) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings2[tp.i] = siblingsToZKInputFormat(pReceiver.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings2[txProcessor.txIndex] = siblingsToZKInputFormat(pReceiver.Siblings) } return nil @@ -1110,8 +1133,8 @@ func (tp *TxProcessor) applyTransfer(coordIdxsMap map[common.TokenID]common.Idx, // applyCreateAccountDepositTransfer, in a single tx, creates a new account, // makes a deposit, and performs a transfer to another account -func (tp *TxProcessor) applyCreateAccountDepositTransfer(tx *common.L1Tx) error { - auxFromIdx := common.Idx(tp.s.CurrentIdx() + 1) +func (txProcessor *TxProcessor) applyCreateAccountDepositTransfer(tx *common.L1Tx) error { + auxFromIdx := common.Idx(txProcessor.state.CurrentIdx() + 1) accSender := &common.Account{ TokenID: tx.TokenID, Nonce: 0, @@ -1120,17 +1143,17 @@ func (tp *TxProcessor) applyCreateAccountDepositTransfer(tx *common.L1Tx) error EthAddr: tx.FromEthAddr, } - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State1 before updating the Sender leaf - tp.zki.TokenID1[tp.i] = tx.TokenID.BigInt() - tp.zki.Nonce1[tp.i] = big.NewInt(0) + txProcessor.zki.TokenID1[txProcessor.txIndex] = tx.TokenID.BigInt() + txProcessor.zki.Nonce1[txProcessor.txIndex] = big.NewInt(0) fromBJJSign, fromBJJY := babyjub.UnpackSignY(tx.FromBJJ) if fromBJJSign { - tp.zki.Sign1[tp.i] = big.NewInt(1) + txProcessor.zki.Sign1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay1[tp.i] = fromBJJY - tp.zki.Balance1[tp.i] = tx.EffectiveDepositAmount - tp.zki.EthAddr1[tp.i] = common.EthAddrToBigInt(tx.FromEthAddr) + txProcessor.zki.Ay1[txProcessor.txIndex] = fromBJJY + txProcessor.zki.Balance1[txProcessor.txIndex] = tx.EffectiveDepositAmount + txProcessor.zki.EthAddr1[txProcessor.txIndex] = common.EthAddrToBigInt(tx.FromEthAddr) } // subtract amount to the sender @@ -1140,86 +1163,85 @@ func (tp *TxProcessor) applyCreateAccountDepositTransfer(tx *common.L1Tx) error } // create Account of the Sender - p, err := tp.createAccount(common.Idx(tp.s.CurrentIdx()+1), accSender) + p, err := txProcessor.createAccount(common.Idx(txProcessor.state.CurrentIdx()+1), accSender) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings1[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings1[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 { - tp.zki.IsOld0_1[tp.i] = big.NewInt(1) + txProcessor.zki.IsOld0_1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.OldKey1[tp.i] = p.OldKey.BigInt() - tp.zki.OldValue1[tp.i] = p.OldValue.BigInt() - - tp.zki.Metadata.NewLastIdxRaw = tp.s.CurrentIdx() + 1 + txProcessor.zki.OldKey1[txProcessor.txIndex] = p.OldKey.BigInt() + txProcessor.zki.OldValue1[txProcessor.txIndex] = p.OldValue.BigInt() - tp.zki.AuxFromIdx[tp.i] = auxFromIdx.BigInt() - tp.zki.NewAccount[tp.i] = big.NewInt(1) - - // intermediate states - tp.zki.ISOnChain[tp.i] = big.NewInt(1) + txProcessor.zki.Metadata.NewLastIdxRaw = txProcessor.state.CurrentIdx() + 1 + if txProcessor.txIndex < len(txProcessor.zki.ISOnChain) { + txProcessor.zki.ISOnChain[txProcessor.txIndex] = big.NewInt(1) + } + txProcessor.zki.AuxFromIdx[txProcessor.txIndex] = auxFromIdx.BigInt() + txProcessor.zki.NewAccount[txProcessor.txIndex] = big.NewInt(1) } var accReceiver *common.Account if tx.ToIdx == auxFromIdx { accReceiver = accSender } else { - accReceiver, err = tp.s.GetAccount(tx.ToIdx) + accReceiver, err = txProcessor.state.GetAccount(tx.ToIdx) if err != nil { log.Error(err) return tracerr.Wrap(err) } } - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State2 before updating the Receiver leaf - tp.zki.TokenID2[tp.i] = accReceiver.TokenID.BigInt() - tp.zki.Nonce2[tp.i] = accReceiver.Nonce.BigInt() + txProcessor.zki.TokenID2[txProcessor.txIndex] = accReceiver.TokenID.BigInt() + txProcessor.zki.Nonce2[txProcessor.txIndex] = accReceiver.Nonce.BigInt() receiverBJJSign, receiverBJJY := babyjub.UnpackSignY(accReceiver.BJJ) if receiverBJJSign { - tp.zki.Sign2[tp.i] = big.NewInt(1) + txProcessor.zki.Sign2[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay2[tp.i] = receiverBJJY - tp.zki.Balance2[tp.i] = accReceiver.Balance - tp.zki.EthAddr2[tp.i] = common.EthAddrToBigInt(accReceiver.EthAddr) + txProcessor.zki.Ay2[txProcessor.txIndex] = receiverBJJY + txProcessor.zki.Balance2[txProcessor.txIndex] = accReceiver.Balance + txProcessor.zki.EthAddr2[txProcessor.txIndex] = common.EthAddrToBigInt(accReceiver.EthAddr) } // add amount to the receiver accReceiver.Balance = new(big.Int).Add(accReceiver.Balance, tx.EffectiveAmount) // update receiver account in localStateDB - p, err = tp.updateAccount(tx.ToIdx, accReceiver) + p, err = txProcessor.updateAccount(tx.ToIdx, accReceiver) if err != nil { return tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings2[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings2[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) } - return tp.s.SetCurrentIdx(tp.s.CurrentIdx() + 1) + return txProcessor.state.SetCurrentIdx(txProcessor.state.CurrentIdx() + 1) } // It returns the ExitAccount and a boolean determining if the Exit created a // new Leaf in the ExitTree. -func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, +func (txProcessor *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, collectedFees map[common.TokenID]*big.Int, exitTree *merkletree.MerkleTree, tx common.Tx, originalAmount *big.Int) (*common.Account, bool, error) { // 0. subtract tx.Amount from current Account in StateMT // add the tx.Amount into the Account (tx.FromIdx) in the ExitMT - acc, err := tp.s.GetAccount(tx.FromIdx) + acc, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { return nil, false, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.TokenID1[tp.i] = acc.TokenID.BigInt() - tp.zki.Nonce1[tp.i] = acc.Nonce.BigInt() + if txProcessor.zki != nil { + txProcessor.zki.TokenID1[txProcessor.txIndex] = acc.TokenID.BigInt() + txProcessor.zki.Nonce1[txProcessor.txIndex] = acc.Nonce.BigInt() accBJJSign, accBJJY := babyjub.UnpackSignY(acc.BJJ) if accBJJSign { - tp.zki.Sign1[tp.i] = big.NewInt(1) + txProcessor.zki.Sign1[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay1[tp.i] = accBJJY - tp.zki.Balance1[tp.i] = acc.Balance - tp.zki.EthAddr1[tp.i] = common.EthAddrToBigInt(acc.EthAddr) + txProcessor.zki.Ay1[txProcessor.txIndex] = accBJJY + txProcessor.zki.Balance1[txProcessor.txIndex] = acc.Balance + txProcessor.zki.EthAddr1[txProcessor.txIndex] = common.EthAddrToBigInt(acc.EthAddr) } if !tx.IsL1 { @@ -1238,7 +1260,7 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, } if _, ok := coordIdxsMap[acc.TokenID]; ok { - accCoord, err := tp.s.GetAccount(coordIdxsMap[acc.TokenID]) + accCoord, err := txProcessor.state.GetAccount(coordIdxsMap[acc.TokenID]) if err != nil { return nil, false, tracerr.Wrap( fmt.Errorf("Can not use CoordIdx that does not exist in the tree. TokenID: %d, CoordIdx: %d", @@ -1246,11 +1268,15 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, } // accumulate the fee for the Coord account - accumulated := tp.AccumulatedFees[accCoord.Idx] + accumulated, ok := txProcessor.AccumulatedFees[accCoord.Idx] + if !ok { + accumulated = big.NewInt(0) + txProcessor.AccumulatedFees[accCoord.Idx] = accumulated + } accumulated.Add(accumulated, fee) - if tp.s.Type() == statedb.TypeSynchronizer || - tp.s.Type() == statedb.TypeBatchBuilder { + if txProcessor.state.Type() == statedb.TypeSynchronizer || + txProcessor.state.Type() == statedb.TypeBatchBuilder { collected := collectedFees[accCoord.TokenID] collected.Add(collected, fee) } @@ -1264,12 +1290,12 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, } } - p, err := tp.updateAccount(tx.FromIdx, acc) + p, err := txProcessor.updateAccount(tx.FromIdx, acc) if err != nil { return nil, false, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings1[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings1[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) } if exitTree == nil { @@ -1304,34 +1330,36 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, BJJ: acc.BJJ, EthAddr: acc.EthAddr, } - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State2 before creating the Exit leaf - tp.zki.TokenID2[tp.i] = acc.TokenID.BigInt() - tp.zki.Nonce2[tp.i] = big.NewInt(0) + txProcessor.zki.TokenID2[txProcessor.txIndex] = acc.TokenID.BigInt() + txProcessor.zki.Nonce2[txProcessor.txIndex] = big.NewInt(0) accBJJSign, accBJJY := babyjub.UnpackSignY(acc.BJJ) if accBJJSign { - tp.zki.Sign2[tp.i] = big.NewInt(1) + txProcessor.zki.Sign2[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay2[tp.i] = accBJJY + txProcessor.zki.Ay2[txProcessor.txIndex] = accBJJY // Balance2 contains the ExitLeaf Balance before the // leaf update, which is 0 - tp.zki.Balance2[tp.i] = big.NewInt(0) - tp.zki.EthAddr2[tp.i] = common.EthAddrToBigInt(acc.EthAddr) + txProcessor.zki.Balance2[txProcessor.txIndex] = big.NewInt(0) + txProcessor.zki.EthAddr2[txProcessor.txIndex] = common.EthAddrToBigInt(acc.EthAddr) // as Leaf didn't exist in the ExitTree, set NewExit[i]=1 - tp.zki.NewExit[tp.i] = big.NewInt(1) + txProcessor.zki.NewExit[txProcessor.txIndex] = big.NewInt(1) } p, err = statedb.CreateAccountInTreeDB(exitTree.DB(), exitTree, tx.FromIdx, exitAccount) if err != nil { return nil, false, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings2[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings2[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 { - tp.zki.IsOld0_2[tp.i] = big.NewInt(1) + txProcessor.zki.IsOld0_2[txProcessor.txIndex] = big.NewInt(1) + } + if txProcessor.txIndex < len(txProcessor.zki.ISExitRoot) { + txProcessor.zki.ISExitRoot[txProcessor.txIndex] = exitTree.Root().BigInt() } - tp.zki.OldKey2[tp.i] = p.OldKey.BigInt() - tp.zki.OldValue2[tp.i] = p.OldValue.BigInt() - tp.zki.ISExitRoot[tp.i] = exitTree.Root().BigInt() + txProcessor.zki.OldKey2[txProcessor.txIndex] = p.OldKey.BigInt() + txProcessor.zki.OldValue2[txProcessor.txIndex] = p.OldValue.BigInt() } return exitAccount, true, nil } else if err != nil { @@ -1339,20 +1367,20 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, } // 1b. if idx already exist in exitTree: - if tp.zki != nil { + if txProcessor.zki != nil { // Set the State2 before updating the Exit leaf - tp.zki.TokenID2[tp.i] = acc.TokenID.BigInt() + txProcessor.zki.TokenID2[txProcessor.txIndex] = acc.TokenID.BigInt() // increment nonce from existing ExitLeaf - tp.zki.Nonce2[tp.i] = exitAccount.Nonce.BigInt() + txProcessor.zki.Nonce2[txProcessor.txIndex] = exitAccount.Nonce.BigInt() accBJJSign, accBJJY := babyjub.UnpackSignY(acc.BJJ) if accBJJSign { - tp.zki.Sign2[tp.i] = big.NewInt(1) + txProcessor.zki.Sign2[txProcessor.txIndex] = big.NewInt(1) } - tp.zki.Ay2[tp.i] = accBJJY + txProcessor.zki.Ay2[txProcessor.txIndex] = accBJJY // Balance2 contains the ExitLeaf Balance before the leaf // update - tp.zki.Balance2[tp.i] = exitAccount.Balance - tp.zki.EthAddr2[tp.i] = common.EthAddrToBigInt(acc.EthAddr) + txProcessor.zki.Balance2[txProcessor.txIndex] = exitAccount.Balance + txProcessor.zki.EthAddr2[txProcessor.txIndex] = common.EthAddrToBigInt(acc.EthAddr) } // update account, where account.Balance += exitAmount @@ -1362,21 +1390,23 @@ func (tp *TxProcessor) applyExit(coordIdxsMap map[common.TokenID]common.Idx, return nil, false, tracerr.Wrap(err) } - if tp.zki != nil { - tp.zki.Siblings2[tp.i] = siblingsToZKInputFormat(p.Siblings) + if txProcessor.zki != nil { + txProcessor.zki.Siblings2[txProcessor.txIndex] = siblingsToZKInputFormat(p.Siblings) if p.IsOld0 { - tp.zki.IsOld0_2[tp.i] = big.NewInt(1) + txProcessor.zki.IsOld0_2[txProcessor.txIndex] = big.NewInt(1) + } + txProcessor.zki.OldKey2[txProcessor.txIndex] = p.OldKey.BigInt() + txProcessor.zki.OldValue2[txProcessor.txIndex] = p.OldValue.BigInt() + if txProcessor.txIndex < len(txProcessor.zki.ISExitRoot) { + txProcessor.zki.ISExitRoot[txProcessor.txIndex] = exitTree.Root().BigInt() } - tp.zki.OldKey2[tp.i] = p.OldKey.BigInt() - tp.zki.OldValue2[tp.i] = p.OldValue.BigInt() - tp.zki.ISExitRoot[tp.i] = exitTree.Root().BigInt() } return exitAccount, false, nil } // computeEffectiveAmounts checks that the L1Tx data is correct -func (tp *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { +func (txProcessor *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { tx.EffectiveAmount = tx.Amount tx.EffectiveDepositAmount = tx.DepositAmount @@ -1400,7 +1430,7 @@ func (tp *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { } // check if tx.TokenID==receiver.TokenID - accReceiver, err := tp.s.GetAccount(tx.ToIdx) + accReceiver, err := txProcessor.state.GetAccount(tx.ToIdx) if err != nil { log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: can not get account for tx.ToIdx: %d", tx.ToIdx) @@ -1417,7 +1447,7 @@ func (tp *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { return } - accSender, err := tp.s.GetAccount(tx.FromIdx) + accSender, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: can not get account for tx.FromIdx: %d", tx.FromIdx) @@ -1463,7 +1493,7 @@ func (tp *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { } // check that TokenID is the same for Sender & Receiver account - accReceiver, err := tp.s.GetAccount(tx.ToIdx) + accReceiver, err := txProcessor.state.GetAccount(tx.ToIdx) if err != nil { log.Debugf("EffectiveAmount & EffectiveDepositAmount = 0: can not get account for tx.ToIdx: %d", tx.ToIdx) @@ -1490,8 +1520,8 @@ func (tp *TxProcessor) computeEffectiveAmounts(tx *common.L1Tx) { // balance in the account to send the Amount+Fee, and also returns the account // Balance and the Fee+Amount (which is used to give information about why the // transaction is not selected in case that this method returns false. -func (tp *TxProcessor) CheckEnoughBalance(tx common.PoolL2Tx) (bool, *big.Int, *big.Int) { - acc, err := tp.s.GetAccount(tx.FromIdx) +func (txProcessor *TxProcessor) CheckEnoughBalance(tx common.PoolL2Tx) (bool, *big.Int, *big.Int) { + acc, err := txProcessor.state.GetAccount(tx.FromIdx) if err != nil { return false, nil, nil } diff --git a/txprocessor/txprocessor_test.go b/txprocessor/txprocessor_test.go index 950204802..6ce859ae0 100644 --- a/txprocessor/txprocessor_test.go +++ b/txprocessor/txprocessor_test.go @@ -30,16 +30,16 @@ func TestMain(m *testing.M) { os.Exit(exitVal) } -func checkBalance(t *testing.T, tc *til.Context, sdb *statedb.StateDB, username string, +func checkBalance(t *testing.T, tc *til.Context, statedb *statedb.StateDB, username string, tokenid int, expected string) { idx := tc.Users[username].Accounts[common.TokenID(tokenid)].Idx - acc, err := sdb.GetAccount(idx) + acc, err := statedb.GetAccount(idx) require.NoError(t, err) assert.Equal(t, expected, acc.Balance.String()) } -func checkBalanceByIdx(t *testing.T, sdb *statedb.StateDB, idx common.Idx, expected string) { - acc, err := sdb.GetAccount(idx) +func checkBalanceByIdx(t *testing.T, statedb *statedb.StateDB, idx common.Idx, expected string) { + acc, err := statedb.GetAccount(idx) require.NoError(t, err) assert.Equal(t, expected, acc.Balance.String()) } @@ -49,7 +49,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeSynchronizer, NLevels: 32}) assert.NoError(t, err) @@ -76,8 +76,8 @@ func TestComputeEffectiveAmounts(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) - _, err = tp.ProcessTxs(nil, blocks[0].Rollup.L1UserTxs, nil, nil) + txProcessor := NewTxProcessor(statedb, config) + _, err = txProcessor.ProcessTxs(nil, blocks[0].Rollup.L1UserTxs, nil, nil) require.NoError(t, err) tx := common.L1Tx{ @@ -88,7 +88,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["A"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(10), tx.EffectiveAmount) @@ -101,7 +101,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["A"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -114,7 +114,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { DepositAmount: big.NewInt(10), UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(10), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(10), tx.EffectiveAmount) @@ -127,7 +127,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { DepositAmount: big.NewInt(10), UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(10), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -140,7 +140,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["A"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -153,7 +153,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["B"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(0), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -167,7 +167,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["A"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(8), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -182,7 +182,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { FromEthAddr: tc.Users["B"].Addr, UserOrigin: true, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(8), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -199,7 +199,7 @@ func TestComputeEffectiveAmounts(t *testing.T) { UserOrigin: true, Type: common.TxTypeCreateAccountDepositTransfer, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(8), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) @@ -216,11 +216,11 @@ func TestComputeEffectiveAmounts(t *testing.T) { UserOrigin: true, Type: common.TxTypeDepositTransfer, } - tp.computeEffectiveAmounts(&tx) + txProcessor.computeEffectiveAmounts(&tx) assert.Equal(t, big.NewInt(8), tx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), tx.EffectiveAmount) - sdb.Close() + statedb.Close() } func TestProcessTxsBalances(t *testing.T) { @@ -228,7 +228,7 @@ func TestProcessTxsBalances(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeSynchronizer, NLevels: 32}) assert.NoError(t, err) @@ -245,147 +245,147 @@ func TestProcessTxsBalances(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) log.Debug("block:0 batch:1, only L1CoordinatorTxs") - _, err = tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) + _, err = txProcessor.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) require.NoError(t, err) - assert.Equal(t, "0", tp.s.MT.Root().BigInt().String()) + assert.Equal(t, "0", txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:2") l1UserTxs := []common.L1Tx{} l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - _, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - assert.Equal(t, "0", tp.s.MT.Root().BigInt().String()) + assert.Equal(t, "0", txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:3") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs) - _, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - checkBalance(t, tc, sdb, "A", 0, "500") + checkBalance(t, tc, statedb, "A", 0, "500") assert.Equal(t, "10303926118213025243660668481827257778714122989909761705455084995854999537039", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:4") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[3].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[3].L2Txs) - _, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - checkBalance(t, tc, sdb, "A", 0, "500") - checkBalance(t, tc, sdb, "A", 1, "500") + checkBalance(t, tc, statedb, "A", 0, "500") + checkBalance(t, tc, statedb, "A", 1, "500") assert.Equal(t, "8530501758307821623834726627056947648600328521261384179220598288701741436285", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:5") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[4].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[4].L2Txs) - _, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - checkBalance(t, tc, sdb, "A", 0, "500") - checkBalance(t, tc, sdb, "A", 1, "500") + checkBalance(t, tc, statedb, "A", 0, "500") + checkBalance(t, tc, statedb, "A", 1, "500") assert.Equal(t, "8530501758307821623834726627056947648600328521261384179220598288701741436285", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:6") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[5].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[5].L2Txs) - _, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - checkBalance(t, tc, sdb, "A", 0, "600") - checkBalance(t, tc, sdb, "A", 1, "500") - checkBalance(t, tc, sdb, "B", 0, "400") + checkBalance(t, tc, statedb, "A", 0, "600") + checkBalance(t, tc, statedb, "A", 1, "500") + checkBalance(t, tc, statedb, "B", 0, "400") assert.Equal(t, "9061858435528794221929846392270405504056106238451760714188625065949729889651", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) coordIdxs := []common.Idx{261, 263} log.Debug("block:0 batch:7") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[6].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[6].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[6].L1CoordinatorTxs, l2Txs) - require.NoError(t, err) - checkBalance(t, tc, sdb, "Coord", 0, "10") - checkBalance(t, tc, sdb, "Coord", 1, "20") - checkBalance(t, tc, sdb, "A", 0, "600") - checkBalance(t, tc, sdb, "A", 1, "280") - checkBalance(t, tc, sdb, "B", 0, "290") - checkBalance(t, tc, sdb, "B", 1, "200") - checkBalance(t, tc, sdb, "C", 0, "100") - checkBalance(t, tc, sdb, "D", 0, "800") + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[6].L1CoordinatorTxs, l2Txs) + require.NoError(t, err) + checkBalance(t, tc, statedb, "Coord", 0, "10") + checkBalance(t, tc, statedb, "Coord", 1, "20") + checkBalance(t, tc, statedb, "A", 0, "600") + checkBalance(t, tc, statedb, "A", 1, "280") + checkBalance(t, tc, statedb, "B", 0, "290") + checkBalance(t, tc, statedb, "B", 1, "200") + checkBalance(t, tc, statedb, "C", 0, "100") + checkBalance(t, tc, statedb, "D", 0, "800") assert.Equal(t, "4392049343656836675348565048374261353937130287163762821533580216441778455298", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) log.Debug("block:0 batch:8") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[7].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[7].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[7].L1CoordinatorTxs, l2Txs) - require.NoError(t, err) - checkBalance(t, tc, sdb, "Coord", 0, "35") - checkBalance(t, tc, sdb, "Coord", 1, "30") - checkBalance(t, tc, sdb, "A", 0, "430") - checkBalance(t, tc, sdb, "A", 1, "280") - checkBalance(t, tc, sdb, "B", 0, "390") - checkBalance(t, tc, sdb, "B", 1, "90") - checkBalance(t, tc, sdb, "C", 0, "45") - checkBalance(t, tc, sdb, "C", 1, "100") - checkBalance(t, tc, sdb, "D", 0, "800") + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[7].L1CoordinatorTxs, l2Txs) + require.NoError(t, err) + checkBalance(t, tc, statedb, "Coord", 0, "35") + checkBalance(t, tc, statedb, "Coord", 1, "30") + checkBalance(t, tc, statedb, "A", 0, "430") + checkBalance(t, tc, statedb, "A", 1, "280") + checkBalance(t, tc, statedb, "B", 0, "390") + checkBalance(t, tc, statedb, "B", 1, "90") + checkBalance(t, tc, statedb, "C", 0, "45") + checkBalance(t, tc, statedb, "C", 1, "100") + checkBalance(t, tc, statedb, "D", 0, "800") assert.Equal(t, "8905191229562583213069132470917469035834300549892959854483573322676101624713", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) coordIdxs = []common.Idx{262} log.Debug("block:1 batch:1") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[0].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[0].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) - require.NoError(t, err) - checkBalance(t, tc, sdb, "Coord", 1, "30") - checkBalance(t, tc, sdb, "Coord", 0, "35") - checkBalance(t, tc, sdb, "A", 0, "730") - checkBalance(t, tc, sdb, "A", 1, "280") - checkBalance(t, tc, sdb, "B", 0, "380") - checkBalance(t, tc, sdb, "B", 1, "90") - checkBalance(t, tc, sdb, "C", 0, "845") - checkBalance(t, tc, sdb, "C", 1, "100") - checkBalance(t, tc, sdb, "D", 0, "470") + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) + require.NoError(t, err) + checkBalance(t, tc, statedb, "Coord", 1, "30") + checkBalance(t, tc, statedb, "Coord", 0, "35") + checkBalance(t, tc, statedb, "A", 0, "730") + checkBalance(t, tc, statedb, "A", 1, "280") + checkBalance(t, tc, statedb, "B", 0, "380") + checkBalance(t, tc, statedb, "B", 1, "90") + checkBalance(t, tc, statedb, "C", 0, "845") + checkBalance(t, tc, statedb, "C", 1, "100") + checkBalance(t, tc, statedb, "D", 0, "470") assert.Equal(t, "12063160053709941400160547588624831667157042937323422396363359123696668555050", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) coordIdxs = []common.Idx{} log.Debug("block:1 batch:2") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[1].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "20375835796927052406196249140510136992262283055544831070430919054949353249481", - tp.s.MT.Root().BigInt().String()) + txProcessor.state.MT.Root().BigInt().String()) // use Set of PoolL2 txs poolL2Txs, err := tc.GeneratePoolL2Txs(txsets.SetPoolL2MinimumFlow1) assert.NoError(t, err) - _, err = tp.ProcessTxs(coordIdxs, []common.L1Tx{}, []common.L1Tx{}, poolL2Txs) + _, err = txProcessor.ProcessTxs(coordIdxs, []common.L1Tx{}, []common.L1Tx{}, poolL2Txs) require.NoError(t, err) - checkBalance(t, tc, sdb, "Coord", 1, "30") - checkBalance(t, tc, sdb, "Coord", 0, "35") - checkBalance(t, tc, sdb, "A", 0, "510") - checkBalance(t, tc, sdb, "A", 1, "170") - checkBalance(t, tc, sdb, "B", 0, "480") - checkBalance(t, tc, sdb, "B", 1, "190") - checkBalance(t, tc, sdb, "C", 0, "845") - checkBalance(t, tc, sdb, "C", 1, "100") - checkBalance(t, tc, sdb, "D", 0, "360") - checkBalance(t, tc, sdb, "F", 0, "100") + checkBalance(t, tc, statedb, "Coord", 1, "30") + checkBalance(t, tc, statedb, "Coord", 0, "35") + checkBalance(t, tc, statedb, "A", 0, "510") + checkBalance(t, tc, statedb, "A", 1, "170") + checkBalance(t, tc, statedb, "B", 0, "480") + checkBalance(t, tc, statedb, "B", 1, "190") + checkBalance(t, tc, statedb, "C", 0, "845") + checkBalance(t, tc, statedb, "C", 1, "100") + checkBalance(t, tc, statedb, "D", 0, "360") + checkBalance(t, tc, statedb, "F", 0, "100") - sdb.Close() + statedb.Close() } func TestProcessTxsSynchronizer(t *testing.T) { @@ -393,7 +393,7 @@ func TestProcessTxsSynchronizer(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeSynchronizer, NLevels: 32}) assert.NoError(t, err) @@ -425,19 +425,19 @@ func TestProcessTxsSynchronizer(t *testing.T) { MaxL1Tx: 32, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) // Process the 1st batch, which contains the L1CoordinatorTxs necessary // to create the Coordinator accounts to receive the fees log.Debug("block:0 batch:1, only L1CoordinatorTxs") - ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) + ptOut, err := txProcessor.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) require.NoError(t, err) assert.Equal(t, 4, len(ptOut.CreatedAccounts)) assert.Equal(t, 0, len(ptOut.CollectedFees)) log.Debug("block:0 batch:2") l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - ptOut, err = tp.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, 0, len(ptOut.ExitInfos)) @@ -447,13 +447,13 @@ func TestProcessTxsSynchronizer(t *testing.T) { assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(1)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(2)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(3)].String()) - acc, err := sdb.GetAccount(idxA1) + acc, err := statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "50", acc.Balance.String()) log.Debug("block:0 batch:3") l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs) - ptOut, err = tp.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, 0, len(ptOut.ExitInfos)) assert.Equal(t, 0, len(ptOut.CreatedAccounts)) @@ -462,7 +462,7 @@ func TestProcessTxsSynchronizer(t *testing.T) { assert.Equal(t, "1", ptOut.CollectedFees[common.TokenID(1)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(2)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(3)].String()) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "35", acc.Balance.String()) @@ -479,17 +479,17 @@ func TestProcessTxsSynchronizer(t *testing.T) { idxY1 := tc.Users["Y"].Accounts[common.TokenID(1)].Idx // Idx of user 'Z' idxZ1 := tc.Users["Z"].Accounts[common.TokenID(1)].Idx - accX1, err := sdb.GetAccount(idxX1) + accX1, err := statedb.GetAccount(idxX1) require.NoError(t, err) assert.Equal(t, "25000000000000000010", accX1.Balance.String()) - accY1, err := sdb.GetAccount(idxY1) + accY1, err := statedb.GetAccount(idxY1) require.NoError(t, err) assert.Equal(t, "25000000000000000010", accY1.Balance.String()) - accZ1, err := sdb.GetAccount(idxZ1) + accZ1, err := statedb.GetAccount(idxZ1) require.NoError(t, err) assert.Equal(t, "25000000000000000015", accZ1.Balance.String()) - ptOut, err = tp.ProcessTxs(coordIdxs, nil, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(coordIdxs, nil, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) require.NoError(t, err) // after processing expect l2Txs[0:2].Nonce!=0 and has expected value @@ -509,23 +509,23 @@ func TestProcessTxsSynchronizer(t *testing.T) { assert.Equal(t, big.NewInt(12), ptOut.ExitInfos[2].Balance) assert.Equal(t, big.NewInt(16), ptOut.ExitInfos[3].Balance) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "57", acc.Balance.String()) - accX1, err = sdb.GetAccount(idxX1) + accX1, err = statedb.GetAccount(idxX1) require.NoError(t, err) assert.Equal(t, "24999999999999999976", accX1.Balance.String()) - accY1, err = sdb.GetAccount(idxY1) + accY1, err = statedb.GetAccount(idxY1) require.NoError(t, err) assert.Equal(t, "25000000000000000004", accY1.Balance.String()) - accZ1, err = sdb.GetAccount(idxZ1) + accZ1, err = statedb.GetAccount(idxZ1) require.NoError(t, err) assert.Equal(t, "25000000000000000024", accZ1.Balance.String()) log.Debug("block:1 batch:2") l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs) - ptOut, err = tp.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) // 1, as previous batch was without L1UserTxs, and has pending the @@ -538,21 +538,21 @@ func TestProcessTxsSynchronizer(t *testing.T) { assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(1)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(2)].String()) assert.Equal(t, "0", ptOut.CollectedFees[common.TokenID(3)].String()) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) assert.NoError(t, err) assert.Equal(t, "77", acc.Balance.String()) idxB0 := tc.Users["C"].Accounts[common.TokenID(0)].Idx - acc, err = sdb.GetAccount(idxB0) + acc, err = statedb.GetAccount(idxB0) require.NoError(t, err) assert.Equal(t, "51", acc.Balance.String()) // get balance of Coordinator account for TokenID==0 - acc, err = sdb.GetAccount(common.Idx(256)) + acc, err = statedb.GetAccount(common.Idx(256)) require.NoError(t, err) assert.Equal(t, "2", acc.Balance.String()) - sdb.Close() + statedb.Close() } func TestProcessTxsBatchBuilder(t *testing.T) { @@ -560,7 +560,7 @@ func TestProcessTxsBatchBuilder(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeBatchBuilder, NLevels: 32}) assert.NoError(t, err) @@ -583,74 +583,74 @@ func TestProcessTxsBatchBuilder(t *testing.T) { MaxL1Tx: 32, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) // Process the 1st batch, which contains the L1CoordinatorTxs necessary // to create the Coordinator accounts to receive the fees log.Debug("block:0 batch:1, only L1CoordinatorTxs") - ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) + ptOut, err := txProcessor.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) require.NoError(t, err) // expect 0 at CreatedAccount, as is only computed when StateDB.Type==TypeSynchronizer assert.Equal(t, 0, len(ptOut.CreatedAccounts)) log.Debug("block:0 batch:2") l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - ptOut, err = tp.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, blocks[0].Rollup.L1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, 0, len(ptOut.ExitInfos)) assert.Equal(t, 0, len(ptOut.CreatedAccounts)) - acc, err := sdb.GetAccount(idxA1) + acc, err := statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "50", acc.Balance.String()) log.Debug("block:0 batch:3") l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs) - ptOut, err = tp.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(coordIdxs, nil, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, 0, len(ptOut.ExitInfos)) assert.Equal(t, 0, len(ptOut.CreatedAccounts)) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "35", acc.Balance.String()) log.Debug("block:1 batch:1") l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[0].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, nil, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) + _, err = txProcessor.ProcessTxs(coordIdxs, nil, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) require.NoError(t, err) assert.Equal(t, "57", acc.Balance.String()) log.Debug("block:1 batch:2") l2Txs = common.L2TxsToPoolL2Txs(blocks[1].Rollup.Batches[1].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs, + _, err = txProcessor.ProcessTxs(coordIdxs, blocks[1].Rollup.L1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) - acc, err = sdb.GetAccount(idxA1) + acc, err = statedb.GetAccount(idxA1) assert.NoError(t, err) assert.Equal(t, "77", acc.Balance.String()) idxB0 := tc.Users["C"].Accounts[common.TokenID(0)].Idx - acc, err = sdb.GetAccount(idxB0) + acc, err = statedb.GetAccount(idxB0) require.NoError(t, err) assert.Equal(t, "51", acc.Balance.String()) // get balance of Coordinator account for TokenID==0 - acc, err = sdb.GetAccount(common.Idx(256)) + acc, err = statedb.GetAccount(common.Idx(256)) require.NoError(t, err) assert.Equal(t, common.TokenID(0), acc.TokenID) assert.Equal(t, "2", acc.Balance.String()) - acc, err = sdb.GetAccount(common.Idx(257)) + acc, err = statedb.GetAccount(common.Idx(257)) require.NoError(t, err) assert.Equal(t, common.TokenID(1), acc.TokenID) assert.Equal(t, "2", acc.Balance.String()) assert.Equal(t, "8499500340673457131709907313180428395258466720027480159049632090608270570263", - sdb.MT.Root().BigInt().String()) + statedb.MT.Root().BigInt().String()) - sdb.Close() + statedb.Close() } func TestProcessTxsRootTestVectors(t *testing.T) { @@ -658,7 +658,7 @@ func TestProcessTxsRootTestVectors(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeBatchBuilder, NLevels: 32}) assert.NoError(t, err) @@ -699,14 +699,14 @@ func TestProcessTxsRootTestVectors(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) - _, err = tp.ProcessTxs(nil, l1Txs, nil, l2Txs) + txProcessor := NewTxProcessor(statedb, config) + _, err = txProcessor.ProcessTxs(nil, l1Txs, nil, l2Txs) require.NoError(t, err) assert.Equal(t, "16181420716631932805604732887923905079487577323947343079740042260791593140221", - sdb.MT.Root().BigInt().String()) + statedb.MT.Root().BigInt().String()) - sdb.Close() + statedb.Close() } func TestCreateAccountDepositMaxValue(t *testing.T) { @@ -715,7 +715,7 @@ func TestCreateAccountDepositMaxValue(t *testing.T) { deleteme = append(deleteme, dir) nLevels := 16 - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeBatchBuilder, NLevels: nLevels}) assert.NoError(t, err) @@ -765,20 +765,20 @@ func TestCreateAccountDepositMaxValue(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) - _, err = tp.ProcessTxs(nil, l1Txs, nil, nil) + _, err = txProcessor.ProcessTxs(nil, l1Txs, nil, nil) require.NoError(t, err) // check balances - acc, err := sdb.GetAccount(common.Idx(256)) + acc, err := statedb.GetAccount(common.Idx(256)) require.NoError(t, err) assert.Equal(t, daMaxBI, acc.Balance) - acc, err = sdb.GetAccount(common.Idx(257)) + acc, err = statedb.GetAccount(common.Idx(257)) require.NoError(t, err) assert.Equal(t, daMax1BI, acc.Balance) - sdb.Close() + statedb.Close() } func initTestMultipleCoordIdxForTokenID(t *testing.T) (*TxProcessor, *til.Context, @@ -787,7 +787,7 @@ func initTestMultipleCoordIdxForTokenID(t *testing.T) (*TxProcessor, *til.Contex require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeBatchBuilder, NLevels: 32}) assert.NoError(t, err) @@ -821,12 +821,12 @@ func initTestMultipleCoordIdxForTokenID(t *testing.T) (*TxProcessor, *til.Contex MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) // batch1 - _, err = tp.ProcessTxs(nil, nil, nil, nil) // to simulate the first batch from the Til set + _, err = txProcessor.ProcessTxs(nil, nil, nil, nil) // to simulate the first batch from the Til set require.NoError(t, err) - return tp, tc, blocks, sdb + return txProcessor, tc, blocks, statedb } func TestMultipleCoordIdxForTokenID(t *testing.T) { @@ -834,52 +834,52 @@ func TestMultipleCoordIdxForTokenID(t *testing.T) { // CoordIdx for each TokenID coordIdxs := []common.Idx{257, 257, 257} - tp, tc, blocks, sdb := initTestMultipleCoordIdxForTokenID(t) + txProcessor, tc, blocks, statedb := initTestMultipleCoordIdxForTokenID(t) l1UserTxs := til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[1].Batch.ForgeL1TxsNum]) l1CoordTxs := blocks[0].Rollup.Batches[1].L1CoordinatorTxs l1CoordTxs = append(l1CoordTxs, l1CoordTxs[0]) // duplicate the CoordAccount for TokenID=0 l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - _, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + _, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) - checkBalanceByIdx(t, tp.s, 256, "90") // A - checkBalanceByIdx(t, tp.s, 257, "10") // Coord0 - checkBalanceByIdx(t, tp.s, 258, "100") // B - checkBalanceByIdx(t, tp.s, 259, "0") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 256, "90") // A + checkBalanceByIdx(t, txProcessor.state, 257, "10") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 258, "100") // B + checkBalanceByIdx(t, txProcessor.state, 259, "0") // Coord0 // reset StateDB values coordIdxs = []common.Idx{259, 257} - sdb.Close() - tp, tc, blocks, sdb = initTestMultipleCoordIdxForTokenID(t) + statedb.Close() + txProcessor, tc, blocks, statedb = initTestMultipleCoordIdxForTokenID(t) l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[1].Batch.ForgeL1TxsNum]) l1CoordTxs = blocks[0].Rollup.Batches[1].L1CoordinatorTxs l1CoordTxs = append(l1CoordTxs, l1CoordTxs[0]) // duplicate the CoordAccount for TokenID=0 l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) - checkBalanceByIdx(t, tp.s, 256, "90") // A - checkBalanceByIdx(t, tp.s, 257, "0") // Coord0 - checkBalanceByIdx(t, tp.s, 258, "100") // B - checkBalanceByIdx(t, tp.s, 259, "10") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 256, "90") // A + checkBalanceByIdx(t, txProcessor.state, 257, "0") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 258, "100") // B + checkBalanceByIdx(t, txProcessor.state, 259, "10") // Coord0 // reset StateDB values coordIdxs = []common.Idx{257, 259} - sdb.Close() - tp, tc, blocks, sdb = initTestMultipleCoordIdxForTokenID(t) + statedb.Close() + txProcessor, tc, blocks, statedb = initTestMultipleCoordIdxForTokenID(t) l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[1].Batch.ForgeL1TxsNum]) l1CoordTxs = blocks[0].Rollup.Batches[1].L1CoordinatorTxs l1CoordTxs = append(l1CoordTxs, l1CoordTxs[0]) // duplicate the CoordAccount for TokenID=0 l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - _, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + _, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) - checkBalanceByIdx(t, tp.s, 256, "90") // A - checkBalanceByIdx(t, tp.s, 257, "10") // Coord0 - checkBalanceByIdx(t, tp.s, 258, "100") // B - checkBalanceByIdx(t, tp.s, 259, "0") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 256, "90") // A + checkBalanceByIdx(t, txProcessor.state, 257, "10") // Coord0 + checkBalanceByIdx(t, txProcessor.state, 258, "100") // B + checkBalanceByIdx(t, txProcessor.state, 259, "0") // Coord0 - sdb.Close() + statedb.Close() } func testTwoExits(t *testing.T, stateDBType statedb.TypeStateDB) ([]*ProcessTxOutput, @@ -935,11 +935,11 @@ func testTwoExits(t *testing.T, stateDBType statedb.TypeStateDB) ([]*ProcessTxOu MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) ptOuts := []*ProcessTxOutput{} for _, block := range blocks { for _, batch := range block.Rollup.Batches { - ptOut, err := tp.ProcessTxs(nil, batch.L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, batch.L1UserTxs, nil, nil) require.NoError(t, err) ptOuts = append(ptOuts, ptOut) } @@ -987,11 +987,11 @@ func testTwoExits(t *testing.T, stateDBType statedb.TypeStateDB) ([]*ProcessTxOu err = tc.FillBlocksForgedL1UserTxs(blocks) require.NoError(t, err) - tp = NewTxProcessor(sdb2, config) + txProcessor = NewTxProcessor(sdb2, config) ptOuts2 := []*ProcessTxOutput{} for _, block := range blocks { for _, batch := range block.Rollup.Batches { - ptOut, err := tp.ProcessTxs(nil, batch.L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, batch.L1UserTxs, nil, nil) require.NoError(t, err) ptOuts2 = append(ptOuts2, ptOut) } @@ -1038,11 +1038,11 @@ func testTwoExits(t *testing.T, stateDBType statedb.TypeStateDB) ([]*ProcessTxOu err = tc.FillBlocksForgedL1UserTxs(blocks) require.NoError(t, err) - tp = NewTxProcessor(sdb3, config) + txProcessor = NewTxProcessor(sdb3, config) ptOuts3 := []*ProcessTxOutput{} for _, block := range blocks { for _, batch := range block.Rollup.Batches { - ptOut, err := tp.ProcessTxs(nil, batch.L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, batch.L1UserTxs, nil, nil) require.NoError(t, err) ptOuts3 = append(ptOuts3, ptOut) } @@ -1073,7 +1073,7 @@ func TestExitOf0Amount(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeBatchBuilder, NLevels: 32}) assert.NoError(t, err) @@ -1126,7 +1126,7 @@ func TestExitOf0Amount(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) // For this test are only processed the batches with transactions: // - Batch2, equivalent to Batches[1] @@ -1135,10 +1135,10 @@ func TestExitOf0Amount(t *testing.T) { // - Batch8, equivalent to Batches[7] // process Batch2: - _, err = tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) + _, err = txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) require.NoError(t, err) // process Batch4: - ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[3].L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[3].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "17688031540912620894848983912708704736922099609001460827147265569563156468242", @@ -1146,7 +1146,7 @@ func TestExitOf0Amount(t *testing.T) { exitRootBatch4 := ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String() // process Batch6: - ptOut, err = tp.ProcessTxs(nil, blocks[0].Rollup.Batches[5].L1UserTxs, nil, nil) + ptOut, err = txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[5].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "17688031540912620894848983912708704736922099609001460827147265569563156468242", @@ -1159,11 +1159,11 @@ func TestExitOf0Amount(t *testing.T) { // For the Batch8, as there is only 1 exit with Amount=0, the ExitRoot // should be 0. // process Batch8: - ptOut, err = tp.ProcessTxs(nil, blocks[0].Rollup.Batches[7].L1UserTxs, nil, nil) + ptOut, err = txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[7].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String()) - sdb.Close() + statedb.Close() } func TestUpdatedAccounts(t *testing.T) { @@ -1171,7 +1171,7 @@ func TestUpdatedAccounts(t *testing.T) { require.NoError(t, err) deleteme = append(deleteme, dir) - sdb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, + statedb, err := statedb.NewStateDB(statedb.Config{Path: dir, Keep: 128, Type: statedb.TypeSynchronizer, NLevels: 32}) assert.NoError(t, err) @@ -1217,7 +1217,7 @@ func TestUpdatedAccounts(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(statedb, config) sortedKeys := func(m map[common.Idx]*common.Account) []int { keys := make([]int, 0) @@ -1230,7 +1230,7 @@ func TestUpdatedAccounts(t *testing.T) { for _, batch := range blocks[0].Rollup.Batches { l2Txs := common.L2TxsToPoolL2Txs(batch.L2Txs) - ptOut, err := tp.ProcessTxs(batch.Batch.FeeIdxsCoordinator, batch.L1UserTxs, + ptOut, err := txProcessor.ProcessTxs(batch.Batch.FeeIdxsCoordinator, batch.L1UserTxs, batch.L1CoordinatorTxs, l2Txs) require.NoError(t, err) switch batch.Batch.BatchNum { @@ -1251,7 +1251,7 @@ func TestUpdatedAccounts(t *testing.T) { assert.Equal(t, []int{257, 261}, sortedKeys(ptOut.UpdatedAccounts)) } for idx, updAcc := range ptOut.UpdatedAccounts { - acc, err := sdb.GetAccount(idx) + acc, err := statedb.GetAccount(idx) require.NoError(t, err) // If acc.Balance is 0, set it to 0 with big.NewInt so // that the comparison succeeds. Without this, the @@ -1265,5 +1265,5 @@ func TestUpdatedAccounts(t *testing.T) { } } - sdb.Close() + statedb.Close() } diff --git a/txprocessor/zkinputsgen_test.go b/txprocessor/zkinputsgen_test.go index 28562f0e7..bbce5ec5c 100644 --- a/txprocessor/zkinputsgen_test.go +++ b/txprocessor/zkinputsgen_test.go @@ -56,9 +56,9 @@ func TestZKInputsHashTestVector0(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -111,9 +111,9 @@ func TestZKInputsHashTestVector1(t *testing.T) { MaxL1Tx: 16, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -173,7 +173,7 @@ func TestZKInputsEmpty(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) // 0. Generate a batch from the empty state with no transactions @@ -182,7 +182,7 @@ func TestZKInputsEmpty(t *testing.T) { l1CoordTxs := []common.L1Tx{} l2Txs := []common.PoolL2Tx{} - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "0", sdb.MT.Root().BigInt().String()) @@ -217,7 +217,7 @@ func TestZKInputsEmpty(t *testing.T) { _, coordIdxs, l1UserTxs, l1CoordTxs, l2Txs = txsets.GenerateTxsZKInputs0(t, chainID) - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) rootNonZero := sdb.MT.Root() @@ -244,7 +244,7 @@ func TestZKInputsEmpty(t *testing.T) { l1CoordTxs = []common.L1Tx{} l2Txs = []common.PoolL2Tx{} - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) assert.Equal(t, rootNonZero, sdb.MT.Root()) @@ -301,9 +301,9 @@ func TestZKInputs0(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -362,9 +362,9 @@ func TestZKInputs1(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -430,9 +430,9 @@ func TestZKInputs2(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -506,9 +506,9 @@ func TestZKInputs3(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -582,9 +582,9 @@ func TestZKInputs4(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) // check expected account keys values from tx inputs @@ -658,9 +658,9 @@ func TestZKInputs5(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) - ptOut, err := tp.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) + ptOut, err := txProcessor.ProcessTxs(coordIdxs, l1UserTxs, l1CoordTxs, l2Txs) require.NoError(t, err) assert.Equal(t, @@ -728,7 +728,7 @@ func TestZKInputs6(t *testing.T) { MaxFeeTx: 4, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx) blocks, err := tc.GenerateBlocks(txsets.SetBlockchainMinimumFlow0) @@ -739,7 +739,7 @@ func TestZKInputs6(t *testing.T) { tc.RestartNonces() log.Debug("block:0 batch:1") - ptOut, err := tp.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) + ptOut, err := txProcessor.ProcessTxs(nil, nil, blocks[0].Rollup.Batches[0].L1CoordinatorTxs, nil) require.NoError(t, err) assert.Equal(t, "0", sdb.MT.Root().BigInt().String()) @@ -760,7 +760,7 @@ func TestZKInputs6(t *testing.T) { log.Debug("block:0 batch:2") l1UserTxs := []common.L1Tx{} l2Txs := common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[1].L2Txs) - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "0", sdb.MT.Root().BigInt().String()) @@ -781,7 +781,7 @@ func TestZKInputs6(t *testing.T) { log.Debug("block:0 batch:3") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[2].L2Txs) - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[2].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "10303926118213025243660668481827257778714122989909761705455084995854999537039", @@ -802,7 +802,7 @@ func TestZKInputs6(t *testing.T) { log.Debug("block:0 batch:4") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[3].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[3].L2Txs) - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "8530501758307821623834726627056947648600328521261384179220598288701741436285", @@ -823,7 +823,7 @@ func TestZKInputs6(t *testing.T) { log.Debug("block:0 batch:5") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[4].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[4].L2Txs) - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[4].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "8530501758307821623834726627056947648600328521261384179220598288701741436285", @@ -844,7 +844,7 @@ func TestZKInputs6(t *testing.T) { log.Debug("block:0 batch:6") l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[5].Batch.ForgeL1TxsNum]) l2Txs = common.L2TxsToPoolL2Txs(blocks[0].Rollup.Batches[5].L2Txs) - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[5].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, "9061858435528794221929846392270405504056106238451760714188625065949729889651", @@ -875,7 +875,7 @@ func TestZKInputs6(t *testing.T) { coordIdxs := []common.Idx{261, 263} l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[6].Batch.ForgeL1TxsNum]) l2Txs = poolL2Txs - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[6].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, @@ -907,7 +907,7 @@ func TestZKInputs6(t *testing.T) { l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[7].Batch.ForgeL1TxsNum]) l2Txs = poolL2Txs - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[0].Rollup.Batches[7].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, @@ -938,7 +938,7 @@ func TestZKInputs6(t *testing.T) { l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[0].Batch.ForgeL1TxsNum]) l2Txs = poolL2Txs coordIdxs = []common.Idx{263} - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[0].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, @@ -961,7 +961,7 @@ func TestZKInputs6(t *testing.T) { l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[1].Rollup.Batches[1].Batch.ForgeL1TxsNum]) l2Txs = []common.PoolL2Tx{} coordIdxs = []common.Idx{} - ptOut, err = tp.ProcessTxs(coordIdxs, l1UserTxs, + ptOut, err = txProcessor.ProcessTxs(coordIdxs, l1UserTxs, blocks[1].Rollup.Batches[1].L1CoordinatorTxs, l2Txs) require.NoError(t, err) assert.Equal(t, @@ -1029,10 +1029,10 @@ func TestZKInputsForceExitNotEnoughBalance(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) // process Batch2: - ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "0", ptOut.ZKInputs.Metadata.NewExitRootRaw.BigInt().String()) assert.Equal(t, @@ -1048,7 +1048,7 @@ func TestZKInputsForceExitNotEnoughBalance(t *testing.T) { // printZKInputs(t, ptOut.ZKInputs) // process Batch4: - ptOut, err = tp.ProcessTxs(nil, blocks[0].Rollup.Batches[3].L1UserTxs, nil, nil) + ptOut, err = txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[3].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "9817949306315488277882761441334442702413477797580483156608957607254414748724", @@ -1163,18 +1163,18 @@ func TestZKInputsDepositTransferDifferentTokenIDs(t *testing.T) { MaxFeeTx: 2, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) assert.Equal(t, "256", tc.Users["A"].Accounts[0].Idx.String()) assert.Equal(t, "257", tc.Users["B"].Accounts[1].Idx.String()) // process Batch2: - ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "15840908427090148754401850838287012766516231419678649885722313476293488046059", ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String()) - checkBalanceByIdx(t, tp.s, 256, "100") // A - checkBalanceByIdx(t, tp.s, 257, "100") // B + checkBalanceByIdx(t, txProcessor.state, 256, "100") // A + checkBalanceByIdx(t, txProcessor.state, 257, "100") // B // process Batch4: depositTransferTx := common.L1Tx{ @@ -1187,16 +1187,16 @@ func TestZKInputsDepositTransferDifferentTokenIDs(t *testing.T) { Type: common.TxTypeDepositTransfer, } l1UserTxs := []common.L1Tx{depositTransferTx} - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, nil, nil) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "14230709344017026161842015882701267639148413699586803973757674240329499158042", ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String()) - checkBalanceByIdx(t, tp.s, 256, "300") // A - checkBalanceByIdx(t, tp.s, 257, "100") // B + checkBalanceByIdx(t, txProcessor.state, 256, "300") // A + checkBalanceByIdx(t, txProcessor.state, 257, "100") // B // extra check directly with the Tx - tp.computeEffectiveAmounts(&depositTransferTx) + txProcessor.computeEffectiveAmounts(&depositTransferTx) assert.Equal(t, big.NewInt(200), depositTransferTx.EffectiveDepositAmount) assert.Equal(t, big.NewInt(0), depositTransferTx.EffectiveAmount) @@ -1266,15 +1266,15 @@ func TestZKInputsL1CoordinatorTxsAfterL1Exit(t *testing.T) { MaxFeeTx: 3, ChainID: chainID, } - tp := NewTxProcessor(sdb, config) + txProcessor := NewTxProcessor(sdb, config) // process Batch2: - ptOut, err := tp.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) + ptOut, err := txProcessor.ProcessTxs(nil, blocks[0].Rollup.Batches[1].L1UserTxs, nil, nil) require.NoError(t, err) assert.Equal(t, "13250144760662777978687264077050092444905467656476402514654550449973838329915", ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String()) - checkBalanceByIdx(t, tp.s, 256, "100") // A + checkBalanceByIdx(t, txProcessor.state, 256, "100") // A // batch3 batchPoolL2 := ` @@ -1286,13 +1286,13 @@ func TestZKInputsL1CoordinatorTxsAfterL1Exit(t *testing.T) { // process Batch4: l1UserTxs := blocks[0].Rollup.Batches[3].L1UserTxs - ptOut, err = tp.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, poolL2Txs) + ptOut, err = txProcessor.ProcessTxs(nil, l1UserTxs, blocks[0].Rollup.Batches[3].L1CoordinatorTxs, poolL2Txs) require.NoError(t, err) assert.Equal(t, "2449079255569259710281173899922223113570673452636649748260745275814779988814", ptOut.ZKInputs.Metadata.NewStateRootRaw.BigInt().String()) - checkBalanceByIdx(t, tp.s, 256, "68") // A - checkBalanceByIdx(t, tp.s, 257, "10") // B + checkBalanceByIdx(t, txProcessor.state, 256, "68") // A + checkBalanceByIdx(t, txProcessor.state, 257, "10") // B // Check that all the ISExitRoot values have the expected value, and // that there are no 0 for the L1Coordinator tx slots after the L1User diff --git a/txselector/errors.go b/txselector/errors.go new file mode 100644 index 000000000..8223858d6 --- /dev/null +++ b/txselector/errors.go @@ -0,0 +1,75 @@ +package txselector + +const ( + // Error messages showed in the info field from tx table + + // ErrExitAmount error message returned when an exit with amount 0 is received + ErrExitAmount = "Exits with amount 0 make no sense, not accepting to prevent unintended transactions" + // ErrExitAmountCode error code + ErrExitAmountCode int = 1 + // ErrExitAmountType error type + ErrExitAmountType string = "ErrExit0Amount" + + // ErrUnsupportedMaxNumBatch error message returned when the maximum batch number is exceeded + ErrUnsupportedMaxNumBatch = "MaxNumBatch exceeded" + // ErrUnsupportedMaxNumBatchCode error code + ErrUnsupportedMaxNumBatchCode int = 2 + // ErrUnsupportedMaxNumBatchType error type + ErrUnsupportedMaxNumBatchType string = "ErrUnsupportedMaxNumBatch" + + // ErrSenderNotEnoughBalance error message returned if the sender doesn't have enough balance to send the tx + ErrSenderNotEnoughBalance = "Tx not selected due to not enough Balance at the sender. " + // ErrSenderNotEnoughBalanceCode error code + ErrSenderNotEnoughBalanceCode int = 11 + // ErrSenderNotEnoughBalanceType error type + ErrSenderNotEnoughBalanceType string = "ErrSenderNotEnoughBalance" + + // ErrNoCurrentNonce error message returned if the sender doesn't use the current nonce + ErrNoCurrentNonce = "Tx not selected due to not current Nonce. " + // ErrNoCurrentNonceCode error code + ErrNoCurrentNonceCode int = 12 + // ErrNoCurrentNonceType error type + ErrNoCurrentNonceType string = "ErrNoCurrentNonce" + + // ErrNotEnoughSpaceL1Coordinator error message returned if L2Tx depends on a L1CoordinatorTx and there is not enough space for L1Coordinator + ErrNotEnoughSpaceL1Coordinator = "Tx not selected because the L2Tx depends on a L1CoordinatorTx and there is not enough space for L1Coordinator" + // ErrNotEnoughSpaceL1CoordinatorCode error code + ErrNotEnoughSpaceL1CoordinatorCode int = 13 + // ErrNotEnoughSpaceL1CoordinatorType error type + ErrNotEnoughSpaceL1CoordinatorType string = "ErrNotEnoughSpaceL1Coordinator" + + // ErrTxDiscartedInProcessTxToEthAddrBJJ error message returned if tx is discarted in processTxToEthAddrBJJ + ErrTxDiscartedInProcessTxToEthAddrBJJ = "Tx not selected (in processTxToEthAddrBJJ)" + // ErrTxDiscartedInProcessTxToEthAddrBJJCode error code + ErrTxDiscartedInProcessTxToEthAddrBJJCode int = 14 + // ErrTxDiscartedInProcessTxToEthAddrBJJType error type + ErrTxDiscartedInProcessTxToEthAddrBJJType string = "ErrTxDiscartedInProcessTxToEthAddrBJJ" + + // ErrToIdxNotFound error message returned if the toIdx is not found in the stateDB + ErrToIdxNotFound = "Tx not selected due to tx.ToIdx not found in StateDB. " + // ErrToIdxNotFoundCode error code + ErrToIdxNotFoundCode int = 15 + // ErrToIdxNotFoundType error type + ErrToIdxNotFoundType string = "ErrToIdxNotFound" + + // ErrTxDiscartedInProcessL2Tx error message returned if tx is discarted in ProcessL2Tx + ErrTxDiscartedInProcessL2Tx = "Tx not selected (in ProcessL2Tx)" + // ErrTxDiscartedInProcessL2TxCode error code + ErrTxDiscartedInProcessL2TxCode int = 16 + // ErrTxDiscartedInProcessL2TxType error type + ErrTxDiscartedInProcessL2TxType string = "ErrTxDiscartedInProcessL2Tx" + + // ErrNoAvailableSlots error message returned if there is no available slots for L2Txs + ErrNoAvailableSlots = "Tx not selected due not available slots for L2Txs" + // ErrNoAvailableSlotsCode error code + ErrNoAvailableSlotsCode int = 17 + // ErrNoAvailableSlotsType error type + ErrNoAvailableSlotsType string = "ErrNoAvailableSlots" + + // ErrInvalidAtomicGroup error message returned if an atomic group is malformed + ErrInvalidAtomicGroup = "Tx not selected because it belongs to an atomic group with missing transactions or bad requested transaction" + // ErrInvalidAtomicGroupCode error code + ErrInvalidAtomicGroupCode int = 18 + // ErrInvalidAtomicGroupType error type + ErrInvalidAtomicGroupType string = "ErrInvalidAtomicGroup" +) diff --git a/txselector/txselector.go b/txselector/txselector.go index 0017277eb..4b6701f04 100644 --- a/txselector/txselector.go +++ b/txselector/txselector.go @@ -1,3 +1,63 @@ +/* +Package txselector is responsible to choose the transactions from the pool that will be forged in the next batch. +The main goal is to come with the most profitable selection, always respecting the constrains of the protocol. +This constrains can be splitted in two categories: + +Batch constrains (this information is passed to the txselector as `selectionConfig txprocessor.Config`): +- NLevels: limit the amount of accounts that can be created by NLevels^2 -1. +Note that this constraint is not properly checked, if this situation is reached the entire selection will fail +- MaxFeeTx: maximum amount of different coordinator accounts (idx) that can be used to collect fees. +Note that this constraint is not checked right now, if this situation is reached the `txprocessor` will fail later on preparing the `zki` +- MaxTx: maximum amount of transactions that can fit in a batch, in other words: len(l1UserTxs) + len(l1CoordinatorTxs) + len(l2Txs) <= MaxTx +- MaxL1Tx: maximum amount of L1 transactions that can fit in a batch, in other words: len(l1UserTxs) + len(l1CoordinatorTxs) <= MaxL1Tx + +Transaction constrains (this takes into consideration the txs fetched from the pool and the current state stored in StateDB): +- Sender account exists: `FromIdx` must exist in the `StateDB`, and `tx.TokenID == account.TokenID` has to be respected +- Sender account has enough balance: tx.Amount + fee <= account.Balance +- Sender account has correct nonce: `tx.Nonce == account.Nonce` +- Recipient account exists or can be created: + - In case of transfer to Idx: account MUST already exist on StateDB, and match the `tx.TokenID` + - In case of transfer to Ethereum address: if the account doesn't exists, it can be created through a `l1CoordinatorTx` IF there is a valid `AccountCreationAuthorization` + - In case of transfer to BJJ: if the account doesn't exists, it can be created through a `l1CoordinatorTx` (no need for `AccountCreationAuthorization`) +- Atomic transactions: requested transaction exist and can be linked, +according to the `RqOffset` spec: https://docs.hermez.io/#/developers/protocol/hermez-protocol/circuits/circuits?id=rq-tx-verifier + +Important considerations: +- It's assumed that signatures are correct, since they're checked before inserting txs to the pool +- The state is processed sequentially meaning that each tx that is selected affects the state, in other words: +the order in which txs are selected can make other txs became valid or invalid. +This specially relevant for the constrains `Sender account has enough balance` and `Sender account has correct nonce` +- The creation of accounts using `l1CoordinatorTxs` increments the amount of used L1 transactions. +This has to be taken into consideration for the constrain `MaxL1Tx` + +Current implementation: + +The current approach is simple but effective, specially in a scenario of not having a lot of transactions in the pool most of the time: +0. Process L1UserTxs (this transactions come from the Blockchain and it's mandatory by protocol to forge them) +1. Get transactions from the pool +2. Order transactions by (nonce, fee in USD) +3. Selection loop: iterate over the sorted transactions and split in selected and non selected. +Repeat this process with the non-selected of each iteration until one iteration doesn't return any selected txs +Note that this step is the one that ensures that the constrains are respected. +4. Choose coordinator idxs to collect the fees. Note that `MaxFeeTx` constrain is ignored in this step. +5. Return the selected L2 txs as well as the necessary `l1CoordinatorTxs` the `l1UserTxs` +(this is redundant as the return will always be the same as the input) and the coordinator idxs used to collect fees + +The previous flow description doesn't take in consideration the constrain `Atomic transactions`. +This constrain alters the previous step as follow: +- Atomic transactions are grouped into `AtomicGroups`, and each group has an average fee that is used to sort the transactions together with the non atomic transactions, +in a way that all the atomic transactions from the same group preserve the relative order as found in the pool. +This is done in this way because it's assumed that transactions from the same `AtomicGroup` +have the same `AtomicGroupID`, and are ordered with valid `RqOffset` in the pool. +- If one atomic transaction fails to be processed in the `Selection loop`, +the group will be marked as invalid and the entire process will reboot from the beginning with the only difference being that +txs belonging to failed atomic groups will be discarded before reaching the `Selection loop`. +This is done this way because the state is altered sequentially, so if a transaction belonging to an atomic group is selected, +but later on a transaction from the same group can't be selected, the selection will be invalid since there will be a selected tx that depends on a tx that +doesn't exist in the selection. Right now the mechanism that the StateDB has to revert changes is to go back to a previous checkpoint (checkpoints are created per batch). +This limitation forces the txselector to restart from the beginning of the batch selection. +This should be improved once the StateDB has more granular mechanisms to revert the effects of processed txs. +*/ package txselector // current: very simple version of TxSelector @@ -8,6 +68,7 @@ import ( "sort" ethCommon "github.com/ethereum/go-ethereum/common" + "github.com/hermeznetwork/hermez-node/api" "github.com/hermeznetwork/hermez-node/common" "github.com/hermeznetwork/hermez-node/db/kvdb" "github.com/hermeznetwork/hermez-node/db/l2db" @@ -82,13 +143,7 @@ func (txsel *TxSelector) getCoordIdx(tokenID common.TokenID) (common.Idx, error) // needs to be created, a new L1CoordinatorTx will be returned from this // function. After calling this method, if the l1CoordinatorTx is added to the // selection, positionL1 must be increased 1. -func (txsel *TxSelector) coordAccountForTokenID(l1CoordinatorTxs []common.L1Tx, - tokenID common.TokenID, positionL1 int) (*common.L1Tx, int, error) { - // check if CoordinatorAccount for TokenID is already pending to create - if checkPendingToCreateL1CoordTx(l1CoordinatorTxs, tokenID, - txsel.coordAccount.Addr, txsel.coordAccount.BJJ) { - return nil, positionL1, nil - } +func (txsel *TxSelector) coordAccountForTokenID(tokenID common.TokenID, positionL1 int) (*common.L1Tx, int, error) { _, err := txsel.getCoordIdx(tokenID) if tracerr.Unwrap(err) == statedb.ErrIdxNotFound { // create L1CoordinatorTx to create new CoordAccount for @@ -150,6 +205,12 @@ func (txsel *TxSelector) GetL1L2TxSelection(selectionConfig txprocessor.Config, discardedL2Txs, tracerr.Wrap(err) } +type failedAtomicGroup struct { + id common.AtomicGroupID + failedTxID common.TxID // ID of the tx that made the entire atomic group fail + reason common.TxSelectorError +} + // getL1L2TxSelection returns the selection of L1 + L2 txs. // It returns: the CoordinatorIdxs used to receive the fees of the selected // L2Txs. An array of bytearrays with the signatures of the @@ -185,11 +246,12 @@ func (txsel *TxSelector) getL1L2TxSelection(selectionConfig txprocessor.Config, // - & ProcessL1Tx of L1CoordTx // - Check validity of receiver Account for ToEthAddr / ToBJJ // - Create UserAccount L1CoordTx if needed (and possible) - // - If everything is fine, store l2Tx to validTxs & update NoncesMap + // - If everything is fine, store l2Tx to selectedTxs & update NoncesMap // - Prepare coordIdxsMap & AccumulatedFees // - Distribute AccumulatedFees to CoordIdxs // - MakeCheckpoint - + failedAtomicGroups := []failedAtomicGroup{} +START_SELECTION: txselStateDB := txsel.localAccountsDB.StateDB tp := txprocessor.NewTxProcessor(txselStateDB, selectionConfig) tp.AccumulatedFees = make(map[common.Idx]*big.Int) @@ -203,19 +265,20 @@ func (txsel *TxSelector) getL1L2TxSelection(selectionConfig txprocessor.Config, } } + // Get pending txs from the pool l2TxsFromDB, err := txsel.l2db.GetPendingTxs() if err != nil { return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) } - l2TxsForgable, l2TxsNonForgable := splitL2ForgableAndNonForgable(tp, l2TxsFromDB) + // Filter transactions belonging to failed atomic groups + selectableTxsTmp, discardedTxs := filterFailedAtomicGroups(l2TxsFromDB, failedAtomicGroups) + // Filter invalid atomic groups + selectableTxs, discardedTxsTmp := filterInvalidAtomicGroups(selectableTxsTmp) + discardedTxs = append(discardedTxs, discardedTxsTmp...) // in case that length of l2TxsForgable is 0, no need to continue, there // is no L2Txs to forge at all - if len(l2TxsForgable) == 0 { - var discardedL2Txs []common.PoolL2Tx - for i := 0; i < len(l2TxsNonForgable); i++ { - discardedL2Txs = append(discardedL2Txs, l2TxsNonForgable[i]) - } + if len(selectableTxs) == 0 { err = tp.StateDB().MakeCheckpoint() if err != nil { return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) @@ -224,53 +287,80 @@ func (txsel *TxSelector) getL1L2TxSelection(selectionConfig txprocessor.Config, metric.SelectedL1UserTxs.Set(float64(len(l1UserTxs))) metric.SelectedL1CoordinatorTxs.Set(0) metric.SelectedL2Txs.Set(0) - metric.DiscardedL2Txs.Set(float64(len(discardedL2Txs))) + metric.DiscardedL2Txs.Set(float64(len(discardedTxs))) - return nil, nil, l1UserTxs, nil, nil, discardedL2Txs, nil + return nil, nil, l1UserTxs, nil, nil, discardedTxs, nil } + // Calculate average fee for atomic groups + atomicFeeMap := calculateAtomicGroupsAverageFee(selectableTxs) + + // Initialize selection arrays + + // Used authorizations in the l1CoordinatorTxs var accAuths [][]byte + // Processed txs for necessary account creation + // (fees for coordinator or missing destinatary accounts) var l1CoordinatorTxs []common.L1Tx - var validTxs, discardedL2Txs []common.PoolL2Tx - l2TxsForgable = sortL2Txs(l2TxsForgable) - accAuths, l1CoordinatorTxs, validTxs, discardedL2Txs, err = - txsel.processL2Txs(tp, selectionConfig, len(l1UserTxs), l1UserFutureTxs, - l2TxsForgable, validTxs, discardedL2Txs) - if err != nil { - return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) - } - - // if there is space for more txs get also the NonForgable txs, that may - // be unblocked once the Forgable ones are processed - if len(validTxs) < int(selectionConfig.MaxTx)-(len(l1UserTxs)+len(l1CoordinatorTxs)) { - l2TxsNonForgable = sortL2Txs(l2TxsNonForgable) - var accAuths2 [][]byte - var l1CoordinatorTxs2 []common.L1Tx - accAuths2, l1CoordinatorTxs2, validTxs, discardedL2Txs, err = - txsel.processL2Txs(tp, selectionConfig, - len(l1UserTxs)+len(l1CoordinatorTxs), l1UserFutureTxs, - l2TxsNonForgable, validTxs, discardedL2Txs) + // Processed txs + var selectedTxs []common.PoolL2Tx + // Start selection process + shouldKeepSelectionProcess := true + // Order L2 txs. This has to be done just once, + // as the array will get smaller over iterations, but the order won't be affected + selectableTxs = sortL2Txs(selectableTxs, atomicFeeMap) + for shouldKeepSelectionProcess { + // Process txs and get selection + iteAccAuths, iteL1CoordinatorTxs, iteSelectedTxs, + nonSelectedTxs, invalidTxs, failedAtomicGroup, err := txsel.processL2Txs( + tp, + selectionConfig, + len(l1UserTxs)+len(l1CoordinatorTxs), // Already added L1 Txs + len(selectedTxs), // Already added L2 Txs + l1UserFutureTxs, // Used to prevent the creation of unnecessary accounts + selectableTxs, // Txs that can be selected + ) + if failedAtomicGroup.id != common.EmptyAtomicGroupID { + // An atomic group failed to be processed + // after at least one tx from the group already altered the state. + // Revert state to current batch and start the selection process again, + // ignoring the txs from the group that failed + log.Info(err) + failedAtomicGroups = append(failedAtomicGroups, failedAtomicGroup) + if err := txsel.localAccountsDB.Reset( + txsel.localAccountsDB.CurrentBatch(), false, + ); err != nil { + return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) + } + goto START_SELECTION + } if err != nil { return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) } - - accAuths = append(accAuths, accAuths2...) - l1CoordinatorTxs = append(l1CoordinatorTxs, l1CoordinatorTxs2...) - } else { - // if there is no space for NonForgable txs, put them at the - // discardedL2Txs array - for i := 0; i < len(l2TxsNonForgable); i++ { - l2TxsNonForgable[i].Info = - "Tx not selected due not available slots for L2Txs" - discardedL2Txs = append(discardedL2Txs, l2TxsNonForgable[i]) + // Add iteration results to selection arrays + accAuths = append(accAuths, iteAccAuths...) + l1CoordinatorTxs = append(l1CoordinatorTxs, iteL1CoordinatorTxs...) + selectedTxs = append(selectedTxs, iteSelectedTxs...) + discardedTxs = append(discardedTxs, invalidTxs...) + // Prepare for next iteration + if len(iteSelectedTxs) == 0 { // Stop iterating + // If in this iteration no txs got selected, stop selection process + shouldKeepSelectionProcess = false + // Add non selected txs to the discarded array as at this point they won't get selected + for i := 0; i < len(nonSelectedTxs); i++ { + discardedTxs = append(discardedTxs, nonSelectedTxs[i]) + } + } else { // Keep iterating + // Try to select nonSelected txs in next iteration + selectableTxs = nonSelectedTxs } } // get CoordIdxsMap for the TokenIDs coordIdxsMap := make(map[common.TokenID]common.Idx) - for i := 0; i < len(validTxs); i++ { + for i := 0; i < len(selectedTxs); i++ { // get TokenID from tx.Sender - accSender, err := tp.StateDB().GetAccount(validTxs[i].FromIdx) + accSender, err := tp.StateDB().GetAccount(selectedTxs[i].FromIdx) if err != nil { return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) } @@ -279,7 +369,7 @@ func (txsel *TxSelector) getL1L2TxSelection(selectionConfig txprocessor.Config, coordIdx, err := txsel.getCoordIdx(tokenID) if err != nil { // if err is db.ErrNotFound, should not happen, as all - // the validTxs.TokenID should have a CoordinatorIdx + // the selectedTxs.TokenID should have a CoordinatorIdx // created in the DB at this point return nil, nil, nil, nil, nil, nil, tracerr.Wrap(err) } @@ -323,74 +413,194 @@ func (txsel *TxSelector) getL1L2TxSelection(selectionConfig txprocessor.Config, metric.SelectedL1CoordinatorTxs.Set(float64(len(l1CoordinatorTxs))) metric.SelectedL1UserTxs.Set(float64(len(l1UserTxs))) - metric.SelectedL2Txs.Set(float64(len(validTxs))) - metric.DiscardedL2Txs.Set(float64(len(discardedL2Txs))) + metric.SelectedL2Txs.Set(float64(len(selectedTxs))) + metric.DiscardedL2Txs.Set(float64(len(discardedTxs))) - return coordIdxs, accAuths, l1UserTxs, l1CoordinatorTxs, validTxs, discardedL2Txs, nil + return coordIdxs, accAuths, l1UserTxs, l1CoordinatorTxs, selectedTxs, discardedTxs, nil } -func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, - selectionConfig txprocessor.Config, nL1Txs int, l1UserFutureTxs []common.L1Tx, - l2Txs, validTxs, discardedL2Txs []common.PoolL2Tx) ([][]byte, []common.L1Tx, - []common.PoolL2Tx, []common.PoolL2Tx, error) { - var l1CoordinatorTxs []common.L1Tx - positionL1 := nL1Txs - var accAuths [][]byte +func (txsel *TxSelector) processL2Txs( + tp *txprocessor.TxProcessor, + selectionConfig txprocessor.Config, + nAlreadyProcessedL1Txs, nAlreadyProcessedL2Txs int, + l1UserFutureTxs []common.L1Tx, + l2Txs []common.PoolL2Tx, +) ( + accAuths [][]byte, + // Processed txs for creating accounts (for coordinator fees or destinatary accounts) + l1CoordinatorTxs []common.L1Tx, + // Processed L2Txs + selectedL2Txs []common.PoolL2Tx, + // L2Txs that are not selected but could get selected in future iterations + nonSelectedL2Txs []common.PoolL2Tx, + // Discarded txs that are impossible to forge + // (nonce too small or impossible to create destinatary account) + unforjableL2Txs []common.PoolL2Tx, + // Info for the atomic group that failed (potentially) + failedAG failedAtomicGroup, + err error, +) { + const failedGroupErrMsg = "Failed forging atomic tx from Group %s." + + " Restarting selection process without txs from this group" + // TODO: differentiate between nonSelectedL2Txs and unforjableL2Txs + // (right now all fall into nonSelectedL2Txs, which is safe but non optimal) + positionL1 := nAlreadyProcessedL1Txs + nextBatchNum := uint32(txsel.localAccountsDB.CurrentBatch()) + 1 // Iterate over l2Txs // - check Nonces // - check enough Balance for the Amount+Fee // - if needed, create new L1CoordinatorTxs for unexisting ToIdx // - keep used accAuths - // - put the valid txs into validTxs array + // - put the valid txs into selectedTxs array for i := 0; i < len(l2Txs); i++ { // Check if there is space for more L2Txs in the selection - maxL2Txs := int(selectionConfig.MaxTx) - nL1Txs - len(l1CoordinatorTxs) - if len(validTxs) >= maxL2Txs { + if !canAddL2Tx(nAlreadyProcessedL1Txs, nAlreadyProcessedL2Txs, selectionConfig) { + // If tx is atomic, restart process without txs from the atomic group + obj := common.TxSelectorError{ + Message: ErrNoAvailableSlots, + Code: ErrNoAvailableSlotsCode, + Type: ErrNoAvailableSlotsType, + } + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // no more available slots for L2Txs, so mark this tx // but also the rest of remaining txs as discarded for j := i; j < len(l2Txs); j++ { - l2Txs[j].Info = - "Tx not selected due not available slots for L2Txs" - discardedL2Txs = append(discardedL2Txs, l2Txs[j]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[j]) } break } + // Reject tx if the batch that is being selected is greater than MaxNumBatch + if l2Txs[i].MaxNumBatch != 0 && nextBatchNum > l2Txs[i].MaxNumBatch { + obj := common.TxSelectorError{ + Message: ErrUnsupportedMaxNumBatch, + Code: ErrUnsupportedMaxNumBatchCode, + Type: ErrUnsupportedMaxNumBatchType, + } + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + // Tx won't be forjable since the current batch num won't go backwards + unforjableL2Txs = append(unforjableL2Txs, l2Txs[i]) + continue + } + // Discard exits with amount 0 if l2Txs[i].Type == common.TxTypeExit && l2Txs[i].Amount.Cmp(big.NewInt(0)) <= 0 { - l2Txs[i].Info = "Exits with amount 0 have no sense, not accepting to prevent unintended transactions" - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + // If tx is atomic, restart process without txs from the atomic group + obj := common.TxSelectorError{ + Message: ErrExitAmount, + Code: ErrExitAmountCode, + Type: ErrExitAmountType, + } + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + // Although tecnicaly forjable, it won't never get forged with current code + unforjableL2Txs = append(unforjableL2Txs, l2Txs[i]) continue } // get Nonce & TokenID from the Account by l2Tx.FromIdx accSender, err := tp.StateDB().GetAccount(l2Txs[i].FromIdx) if err != nil { - return nil, nil, nil, nil, tracerr.Wrap(err) + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(err) } l2Txs[i].TokenID = accSender.TokenID // Check enough Balance on sender enoughBalance, balance, feeAndAmount := tp.CheckEnoughBalance(l2Txs[i]) if !enoughBalance { + obj := common.TxSelectorError{ + Message: fmt.Sprintf(ErrSenderNotEnoughBalance+"Current sender account Balance: %s, Amount+Fee: %s", + balance.String(), feeAndAmount.String()), + Code: ErrSenderNotEnoughBalanceCode, + Type: ErrSenderNotEnoughBalanceType, + } + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // not valid Amount with current Balance. Discard L2Tx, // and update Info parameter of the tx, and add it to // the discardedTxs array - l2Txs[i].Info = fmt.Sprintf("Tx not selected due to not enough Balance at the sender. "+ - "Current sender account Balance: %s, Amount+Fee: %s", - balance.String(), feeAndAmount.String()) - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } // Check if Nonce is correct if l2Txs[i].Nonce != accSender.Nonce { + obj := common.TxSelectorError{ + Message: fmt.Sprintf(ErrNoCurrentNonce+"Tx.Nonce: %d, Account.Nonce: %d", l2Txs[i].Nonce, accSender.Nonce), + Code: ErrNoCurrentNonceCode, + Type: ErrNoCurrentNonceType, + } + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // not valid Nonce at tx. Discard L2Tx, and update Info // parameter of the tx, and add it to the discardedTxs // array - l2Txs[i].Info = fmt.Sprintf("Tx not selected due to not current Nonce. "+ - "Tx.Nonce: %d, Account.Nonce: %d", l2Txs[i].Nonce, accSender.Nonce) - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } @@ -400,22 +610,41 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, // pending L1CoordinatorTx to create the account for the // Coordinator for that TokenID var newL1CoordTx *common.L1Tx - newL1CoordTx, positionL1, err = - txsel.coordAccountForTokenID(l1CoordinatorTxs, - accSender.TokenID, positionL1) + newL1CoordTx, positionL1, err = txsel.coordAccountForTokenID(accSender.TokenID, positionL1) if err != nil { - return nil, nil, nil, nil, tracerr.Wrap(err) + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(err) } if newL1CoordTx != nil { + obj := common.TxSelectorError{ + Message: ErrNotEnoughSpaceL1Coordinator, + Code: ErrNotEnoughSpaceL1CoordinatorCode, + Type: ErrNotEnoughSpaceL1CoordinatorType, + } // if there is no space for the L1CoordinatorTx as MaxL1Tx, or no space // for L1CoordinatorTx + L2Tx as MaxTx, discard the L2Tx - if len(l1CoordinatorTxs) >= int(selectionConfig.MaxL1Tx)-nL1Txs || - len(l1CoordinatorTxs)+1 >= int(selectionConfig.MaxTx)-nL1Txs { + if !canAddL2TxThatNeedsNewCoordL1Tx( + nAlreadyProcessedL1Txs, + nAlreadyProcessedL2Txs, + selectionConfig, + ) { + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // discard L2Tx, and update Info parameter of // the tx, and add it to the discardedTxs array - l2Txs[i].Info = "Tx not selected because the L2Tx depends on a " + - "L1CoordinatorTx and there is not enough space for L1Coordinator" - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } // increase positionL1 @@ -426,8 +655,9 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, // process the L1CoordTx _, _, _, _, err := tp.ProcessL1Tx(nil, newL1CoordTx) if err != nil { - return nil, nil, nil, nil, tracerr.Wrap(err) + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(err) } + nAlreadyProcessedL1Txs++ } // If tx.ToIdx>=256, tx.ToIdx should exist to localAccountsDB, @@ -439,28 +669,39 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, // of CreateAccountAndDeposit is created. If tx.ToIdx==1, is a // Exit type and is used. if l2Txs[i].ToIdx == 0 { // ToEthAddr/ToBJJ case - validL2Tx, l1CoordinatorTx, accAuth, err := - txsel.processTxToEthAddrBJJ(validTxs, selectionConfig, - nL1Txs, l1UserFutureTxs, l1CoordinatorTxs, - positionL1, l2Txs[i]) + validL2Tx, l1CoordinatorTx, accAuth, err := txsel.processTxToEthAddrBJJ( + selectionConfig, + l1UserFutureTxs, + nAlreadyProcessedL1Txs, + nAlreadyProcessedL2Txs, + positionL1, + l2Txs[i], + ) if err != nil { + obj := common.TxSelectorError{ + Message: fmt.Sprintf(ErrTxDiscartedInProcessTxToEthAddrBJJ+" due to %s", err.Error()), + Code: ErrTxDiscartedInProcessTxToEthAddrBJJCode, + Type: ErrTxDiscartedInProcessTxToEthAddrBJJType, + } log.Debugw("txsel.processTxToEthAddrBJJ", "err", err) + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // Discard L2Tx, and update Info parameter of // the tx, and add it to the discardedTxs array - l2Txs[i].Info = fmt.Sprintf("Tx not selected (in processTxToEthAddrBJJ) due to %s", - err.Error()) - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) - continue - } - // if there is no space for the L1CoordinatorTx as MaxL1Tx, or no space - // for L1CoordinatorTx + L2Tx as MaxTx, discard the L2Tx - if len(l1CoordinatorTxs) >= int(selectionConfig.MaxL1Tx)-nL1Txs || - len(l1CoordinatorTxs)+1 >= int(selectionConfig.MaxTx)-nL1Txs { - // discard L2Tx, and update Info parameter of - // the tx, and add it to the discardedTxs array - l2Txs[i].Info = "Tx not selected because the L2Tx depends on a " + - "L1CoordinatorTx and there is not enough space for L1Coordinator" - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } @@ -484,24 +725,61 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, // process the L1CoordTx _, _, _, _, err := tp.ProcessL1Tx(nil, l1CoordinatorTx) if err != nil { - return nil, nil, nil, nil, tracerr.Wrap(err) + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(err) } + nAlreadyProcessedL1Txs++ } if validL2Tx == nil { - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + // TODO: Missing info on why this tx is not selected? Check l2Txs.Info at this point! + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + obj := common.TxSelectorError{ + Message: l2Txs[i].Info, + Code: l2Txs[i].ErrorCode, + Type: l2Txs[i].ErrorType, + } + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } } else if l2Txs[i].ToIdx >= common.IdxUserThreshold { _, err := txsel.localAccountsDB.GetAccount(l2Txs[i].ToIdx) if err != nil { + obj := common.TxSelectorError{ + Message: fmt.Sprintf(ErrToIdxNotFound+"ToIdx: %d", l2Txs[i].ToIdx), + Code: ErrToIdxNotFoundCode, + Type: ErrToIdxNotFoundType, + } // tx not valid log.Debugw("invalid L2Tx: ToIdx not found in StateDB", "ToIdx", l2Txs[i].ToIdx) + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // Discard L2Tx, and update Info parameter of // the tx, and add it to the discardedTxs array - l2Txs[i].Info = fmt.Sprintf("Tx not selected due to tx.ToIdx not found in StateDB. "+ - "ToIdx: %d", l2Txs[i].ToIdx) - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } } @@ -512,9 +790,9 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, coordIdx, err := txsel.getCoordIdx(tokenID) if err != nil { // if err is db.ErrNotFound, should not happen, as all - // the validTxs.TokenID should have a CoordinatorIdx + // the selectedTxs.TokenID should have a CoordinatorIdx // created in the DB at this point - return nil, nil, nil, nil, + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf("Could not get CoordIdx for TokenID=%d, "+ "due: %s", tokenID, err)) } @@ -528,40 +806,48 @@ func (txsel *TxSelector) processL2Txs(tp *txprocessor.TxProcessor, _, _, _, err = tp.ProcessL2Tx(coordIdxsMap, nil, nil, &l2Txs[i]) if err != nil { + obj := common.TxSelectorError{ + Message: fmt.Sprintf(ErrTxDiscartedInProcessL2Tx+" due to %s", err.Error()), + Code: ErrTxDiscartedInProcessL2TxCode, + Type: ErrTxDiscartedInProcessL2TxType, + } log.Debugw("txselector.getL1L2TxSelection at ProcessL2Tx", "err", err) + // If tx is atomic, restart process without txs from the atomic group + if l2Txs[i].AtomicGroupID != common.EmptyAtomicGroupID { + failedAG = failedAtomicGroup{ + id: l2Txs[i].AtomicGroupID, + failedTxID: l2Txs[i].TxID, + reason: obj, + } + return nil, nil, nil, nil, nil, failedAG, tracerr.Wrap(fmt.Errorf( + failedGroupErrMsg, + l2Txs[i].AtomicGroupID.String(), + )) + } // Discard L2Tx, and update Info parameter of the tx, // and add it to the discardedTxs array - l2Txs[i].Info = fmt.Sprintf("Tx not selected (in ProcessL2Tx) due to %s", - err.Error()) - discardedL2Txs = append(discardedL2Txs, l2Txs[i]) + l2Txs[i].Info = obj.Message + l2Txs[i].ErrorCode = obj.Code + l2Txs[i].ErrorType = obj.Type + nonSelectedL2Txs = append(nonSelectedL2Txs, l2Txs[i]) continue } + nAlreadyProcessedL2Txs++ - validTxs = append(validTxs, l2Txs[i]) + selectedL2Txs = append(selectedL2Txs, l2Txs[i]) } // after this loop, no checks to discard txs should be done - return accAuths, l1CoordinatorTxs, validTxs, discardedL2Txs, nil + return accAuths, l1CoordinatorTxs, selectedL2Txs, nonSelectedL2Txs, unforjableL2Txs, failedAG, nil } // processTxsToEthAddrBJJ process the common.PoolL2Tx in the case where // ToIdx==0, which can be the tx type of ToEthAddr or ToBJJ. If the receiver // does not have an account yet, a new L1CoordinatorTx of type -// CreateAccountDeposit (with 0 as DepositAmount) is created and added to the -// l1CoordinatorTxs array, and then the PoolL2Tx is added into the validTxs -// array. -func (txsel *TxSelector) processTxToEthAddrBJJ(validTxs []common.PoolL2Tx, - selectionConfig txprocessor.Config, nL1UserTxs int, l1UserFutureTxs, - l1CoordinatorTxs []common.L1Tx, positionL1 int, l2Tx common.PoolL2Tx) ( +// CreateAccountDeposit (with 0 as DepositAmount) is created +func (txsel *TxSelector) processTxToEthAddrBJJ( + selectionConfig txprocessor.Config, l1UserFutureTxs []common.L1Tx, + nAlreadyProcessedL1Txs, nAlreadyProcessedL2Txs, positionL1 int, l2Tx common.PoolL2Tx) ( *common.PoolL2Tx, *common.L1Tx, *common.AccountCreationAuth, error) { - // if L2Tx needs a new L1CoordinatorTx of CreateAccount type, and a - // previous L2Tx in the current process already created a - // L1CoordinatorTx of this type, in the DB there still seem that needs - // to create a new L1CoordinatorTx, but as is already created, the tx - // is valid - if checkPendingToCreateL1CoordTx(l1CoordinatorTxs, l2Tx.TokenID, l2Tx.ToEthAddr, l2Tx.ToBJJ) { - return &l2Tx, nil, nil, nil - } - // check if L2Tx receiver account will be created by a L1UserFutureTxs // (in the next batch, the current frozen queue). In that case, the L2Tx // will be discarded at the current batch, even if there is an @@ -600,8 +886,8 @@ func (txsel *TxSelector) processTxToEthAddrBJJ(validTxs []common.PoolL2Tx, if err != nil { // not found, l2Tx will not be added in the selection return nil, nil, nil, - tracerr.Wrap(fmt.Errorf("invalid L2Tx: ToIdx not found "+ - "in StateDB, neither ToEthAddr found in AccountCreationAuths L2DB. ToIdx: %d, ToEthAddr: %s", + tracerr.Wrap(fmt.Errorf("invalid L2Tx: ToIdx not found in StateDB, neither "+ + "ToEthAddr found in AccountCreationAuths L2DB. ToIdx: %d, ToEthAddr: %s", l2Tx.ToIdx, l2Tx.ToEthAddr.Hex())) } if accAuth.BJJ != l2Tx.ToBJJ { @@ -671,8 +957,11 @@ func (txsel *TxSelector) processTxToEthAddrBJJ(validTxs []common.PoolL2Tx, } // if there is no space for the L1CoordinatorTx as MaxL1Tx, or no space // for L1CoordinatorTx + L2Tx as MaxTx, discard the L2Tx - if len(l1CoordinatorTxs) >= int(selectionConfig.MaxL1Tx)-nL1UserTxs || - len(l1CoordinatorTxs)+1 >= int(selectionConfig.MaxTx)-nL1UserTxs { + if !canAddL2TxThatNeedsNewCoordL1Tx( + nAlreadyProcessedL1Txs, + nAlreadyProcessedL2Txs, + selectionConfig, + ) { // L2Tx discarded return nil, nil, nil, tracerr.Wrap(fmt.Errorf("L2Tx discarded due to no available slots " + "for L1CoordinatorTx to create a new account for receiver of L2Tx")) @@ -681,18 +970,6 @@ func (txsel *TxSelector) processTxToEthAddrBJJ(validTxs []common.PoolL2Tx, return &l2Tx, l1CoordinatorTx, accAuth, nil } -func checkPendingToCreateL1CoordTx(l1CoordinatorTxs []common.L1Tx, tokenID common.TokenID, - addr ethCommon.Address, bjj babyjub.PublicKeyComp) bool { - for i := 0; i < len(l1CoordinatorTxs); i++ { - if l1CoordinatorTxs[i].FromEthAddr == addr && - l1CoordinatorTxs[i].TokenID == tokenID && - l1CoordinatorTxs[i].FromBJJ == bjj { - return true - } - } - return false -} - func checkPendingToCreateFutureTxs(l1UserFutureTxs []common.L1Tx, tokenID common.TokenID, addr ethCommon.Address, bjj babyjub.PublicKeyComp) bool { for i := 0; i < len(l1UserFutureTxs); i++ { @@ -710,44 +987,271 @@ func checkPendingToCreateFutureTxs(l1UserFutureTxs []common.L1Tx, tokenID common return false } -// sortL2Txs sorts the PoolL2Txs by AbsoluteFee and then by Nonce -func sortL2Txs(l2Txs []common.PoolL2Tx) []common.PoolL2Tx { - // Sort by absolute fee with SliceStable, so that txs with same +// sortL2Txs sorts the PoolL2Txs by AverageFee if they are atomic and AbsoluteFee +// and then by Nonce if they aren't atomic txs that are within the same atomic group +// are guaranteed to manatin order and consecutiveness. +// Assumption: the order within the atomic groups is correct for l2Txs +func sortL2Txs( + l2Txs []common.PoolL2Tx, + atomicGroupsFee map[common.AtomicGroupID]float64, +) []common.PoolL2Tx { + // Separate atomic txs + atomicGroupsMap := make(map[common.AtomicGroupID][]common.PoolL2Tx) + nonAtomicTxs := []common.PoolL2Tx{} + for i := 0; i < len(l2Txs); i++ { + groupID := l2Txs[i].AtomicGroupID + if groupID != common.EmptyAtomicGroupID { // If it's an atomic tx + // If it's the first tx of the group initialise slice + if _, ok := atomicGroupsMap[groupID]; !ok { + atomicGroupsMap[groupID] = []common.PoolL2Tx{} + } + atomicGroupsMap[groupID] = append(atomicGroupsMap[groupID], l2Txs[i]) + } else { // If it's a non atomic tx + nonAtomicTxs = append(nonAtomicTxs, l2Txs[i]) + } + } + // Sort atomic groups by average fee + // First, convert map to slice + atomicGroups := [][]common.PoolL2Tx{} + for groupID := range atomicGroupsMap { + atomicGroups = append(atomicGroups, atomicGroupsMap[groupID]) + } + sort.SliceStable(atomicGroups, func(i, j int) bool { + // Sort by the average fee of each tx group + // assumption: each atomic group has at least one tx, and they all share the same groupID + return atomicGroupsFee[atomicGroups[i][0].AtomicGroupID] > + atomicGroupsFee[atomicGroups[j][0].AtomicGroupID] + }) + + // Sort non atomic txs by absolute fee with SliceStable, so that txs with same // AbsoluteFee are not rearranged and nonce order is kept in such case - sort.SliceStable(l2Txs, func(i, j int) bool { - return l2Txs[i].AbsoluteFee > l2Txs[j].AbsoluteFee + sort.SliceStable(nonAtomicTxs, func(i, j int) bool { + return nonAtomicTxs[i].AbsoluteFee > nonAtomicTxs[j].AbsoluteFee }) - // sort l2Txs by Nonce. This can be done in many different ways, what + // sort non atomic txs by Nonce. This can be done in many different ways, what // is needed is to output the l2Txs where the Nonce of l2Txs for each // Account is sorted, but the l2Txs can not be grouped by sender Account // neither by Fee. This is because later on the Nonces will need to be // sequential for the zkproof generation. - sort.Slice(l2Txs, func(i, j int) bool { - return l2Txs[i].Nonce < l2Txs[j].Nonce + sort.Slice(nonAtomicTxs, func(i, j int) bool { + return nonAtomicTxs[i].Nonce < nonAtomicTxs[j].Nonce }) - return l2Txs + // Combine atomic and non atomic txs in a single slice, ordering them by AbsoluteFee vs AverageFee + // and making sure that the atomic txs within same groups are consecutive + // and preserve the original order (otherwise the RqOffsets will broke) + sortedL2Txs := []common.PoolL2Tx{} + var nextNonAtomicToAppend, nextAtomicGroupToAppend int + // Iterate until all the non atoic txs has been appended + // OR all the atomic txs inside atomic groups has been appended + for nextNonAtomicToAppend != len(nonAtomicTxs) && nextAtomicGroupToAppend != len(atomicGroups) { + if nonAtomicTxs[nextNonAtomicToAppend].AbsoluteFee > + atomicGroupsFee[atomicGroups[nextAtomicGroupToAppend][0].AtomicGroupID] { + // The fee of the next non atomic txs is greater + // than the average fee of the next atomic group + sortedL2Txs = append(sortedL2Txs, nonAtomicTxs[nextNonAtomicToAppend]) + nextNonAtomicToAppend++ + } else { + // The fee of the next non atomic txs is smaller + // than the average fee of the next atomic group + // append all the txs of the group + sortedL2Txs = append(sortedL2Txs, atomicGroups[nextAtomicGroupToAppend]...) + nextAtomicGroupToAppend++ + } + } + // At this point one of the two slices (nonAtomicTxs and atomicGroups) + // is fully apended to sortedL2Txs while the other is not. Append remaining txs + if nextNonAtomicToAppend == len(nonAtomicTxs) { + // nonAtomicTxs is fully appended, append remaining txs in atomicGroups + for i := nextAtomicGroupToAppend; i < len(atomicGroups); i++ { + sortedL2Txs = append(sortedL2Txs, atomicGroups[i]...) + } + } else { // all txs in atomicGroups appended, append remaining nonAtomicTxs + for i := nextNonAtomicToAppend; i < len(nonAtomicTxs); i++ { + sortedL2Txs = append(sortedL2Txs, nonAtomicTxs[i]) + } + } + return sortedL2Txs } -func splitL2ForgableAndNonForgable(tp *txprocessor.TxProcessor, - l2Txs []common.PoolL2Tx) ([]common.PoolL2Tx, []common.PoolL2Tx) { - var l2TxsForgable, l2TxsNonForgable []common.PoolL2Tx - for i := 0; i < len(l2Txs); i++ { - accSender, err := tp.StateDB().GetAccount(l2Txs[i].FromIdx) - if err != nil { - l2Txs[i].Info = fmt.Sprintf("Invalid transaction, FromIdx account not found %d", l2Txs[i].FromIdx) - l2TxsNonForgable = append(l2TxsNonForgable, l2Txs[i]) +func canAddL2TxThatNeedsNewCoordL1Tx( + nAddedL1Txs, nAddedL2txs int, + selectionConfig txprocessor.Config, +) bool { + return nAddedL1Txs < int(selectionConfig.MaxL1Tx) && // Capacity for L1s already reached + nAddedL1Txs+nAddedL2txs+1 < int(selectionConfig.MaxTx) +} + +func canAddL2Tx(nAddedL1Txs, nAddedL2txs int, selectionConfig txprocessor.Config) bool { + return nAddedL1Txs+nAddedL2txs < int(selectionConfig.MaxTx) +} + +// filterFailedAtomicGroups split the txs into the ones that can be porcessed +// and the ones that can't because they belong to an AtomicGroupID that is part of failedGroups. +// The order of txsToProcess is consistent with the order of txs +func filterFailedAtomicGroups( + txs []common.PoolL2Tx, + faildeGroups []failedAtomicGroup, +) (txsToProcess []common.PoolL2Tx, filteredTxs []common.PoolL2Tx) { + // Filter failed atomic groups + for i := 0; i < len(txs); i++ { + if txs[i].AtomicGroupID == common.EmptyAtomicGroupID { + // Tx is not atomic, not filtering + txsToProcess = append(txsToProcess, txs[i]) continue } + txFailed := false + for _, failedAtomicGroup := range faildeGroups { + if failedAtomicGroup.id == txs[i].AtomicGroupID { + obj := setInfoForFailedAtomicTx( + txs[i].TxID == failedAtomicGroup.failedTxID, + txs[i].AtomicGroupID, + failedAtomicGroup.failedTxID, + failedAtomicGroup.reason, + ) + txs[i].Info = obj.Message + txs[i].ErrorCode = obj.Code + txs[i].ErrorType = obj.Type + filteredTxs = append(filteredTxs, txs[i]) + txFailed = true + break + } + } + if !txFailed { + txsToProcess = append(txsToProcess, txs[i]) + } + } + return txsToProcess, filteredTxs +} - if l2Txs[i].Nonce != accSender.Nonce { - l2Txs[i].Info = fmt.Sprintf("Tx not selected due to wrong nonce, tx nonce %d, account sender nonce %d", - l2Txs[i].Nonce, accSender.Nonce) - l2TxsNonForgable = append(l2TxsNonForgable, l2Txs[i]) +// filterInvalidAtomicGroups split the txs into the ones that can be processed +// and the ones that can't because they belong to an AtomicGroup that is impossible to forge +// due to missing or bad ordered txs +func filterInvalidAtomicGroups( + txs []common.PoolL2Tx, +) (txsToProcess []common.PoolL2Tx, filteredTxs []common.PoolL2Tx) { + // Separate txs into atomic groups + atomicGroups := make(map[common.AtomicGroupID]common.AtomicGroup) + for i := 0; i < len(txs); i++ { + atomicGroupID := txs[i].AtomicGroupID + if atomicGroupID == common.EmptyAtomicGroupID { + // Tx is not atomic, not filtering + txsToProcess = append(txsToProcess, txs[i]) + continue + } + if atomicGroup, ok := atomicGroups[atomicGroupID]; !ok { + atomicGroups[atomicGroupID] = common.AtomicGroup{ + Txs: []common.PoolL2Tx{txs[i]}, + } + } else { + atomicGroup.Txs = append(atomicGroup.Txs, txs[i]) + atomicGroups[atomicGroupID] = atomicGroup + } + } + // Validate atomic groups + for _, atomicGroup := range atomicGroups { + if !isAtomicGroupValid(atomicGroup) { + // Set Info message and add txs of the atomic group to filteredTxs + for i := 0; i < len(atomicGroup.Txs); i++ { + atomicGroup.Txs[i].Info = ErrInvalidAtomicGroup + atomicGroup.Txs[i].ErrorType = ErrInvalidAtomicGroupType + atomicGroup.Txs[i].ErrorCode = ErrInvalidAtomicGroupCode + filteredTxs = append(filteredTxs, atomicGroup.Txs[i]) + } + } else { + // Atomic group is valid, add txs of the atomic group to txsToProcess + for i := 0; i < len(atomicGroup.Txs); i++ { + txsToProcess = append(txsToProcess, atomicGroup.Txs[i]) + } + } + } + return txsToProcess, filteredTxs +} + +func isAtomicGroupValid(atomicGroup common.AtomicGroup) bool { + for i := 0; i < len(atomicGroup.Txs); i++ { + // Find requested tx + rqRelativePosition, err := api.RequestOffset2RelativePosition(atomicGroup.Txs[i].RqOffset) + if err != nil { + return false + } + requestedPosition := i + rqRelativePosition + if requestedPosition > len(atomicGroup.Txs)-1 || requestedPosition < 0 { + return false + } + requestedTx := atomicGroup.Txs[requestedPosition] + // Check if the requested tx match the Rq fields + if atomicGroup.Txs[i].RqFromIdx != requestedTx.FromIdx || + atomicGroup.Txs[i].RqToIdx != requestedTx.ToIdx || + atomicGroup.Txs[i].RqToEthAddr != requestedTx.ToEthAddr || + atomicGroup.Txs[i].RqToBJJ != requestedTx.ToBJJ || + atomicGroup.Txs[i].RqTokenID != requestedTx.TokenID || + atomicGroup.Txs[i].RqFee != requestedTx.Fee || + atomicGroup.Txs[i].RqNonce != requestedTx.Nonce { + // TODO: err should be compliant with txSelectorError + return false + } + // Check amount + if atomicGroup.Txs[i].RqAmount != nil && requestedTx.Amount != nil { + // If both are different to nil + if atomicGroup.Txs[i].RqAmount.Cmp(requestedTx.Amount) != 0 { + // They must have same value (to be valid) + return false + } + } else if atomicGroup.Txs[i].RqAmount != requestedTx.Amount { + // Else they must be both nil (to be valid) + return false + } + } + return true +} + +// calculateAtomicGroupsAverageFee generates a map +// that represents AtomicGroupID => average absolute fee +func calculateAtomicGroupsAverageFee(txs []common.PoolL2Tx) map[common.AtomicGroupID]float64 { + txsPerGroup := make(map[common.AtomicGroupID]int) + groupAverageFee := make(map[common.AtomicGroupID]float64) + // Set sum of absolute fee per group + for i := 0; i < len(txs); i++ { + groupID := txs[i].AtomicGroupID + if groupID == common.EmptyAtomicGroupID { + // Not an atomic tx continue } - l2TxsForgable = append(l2TxsForgable, l2Txs[i]) + // Add the absolute fee to the relevant group and increase the txs counted on the group + if _, ok := groupAverageFee[groupID]; !ok { + groupAverageFee[groupID] = txs[i].AbsoluteFee + txsPerGroup[groupID] = 1 + } else { + groupAverageFee[groupID] += txs[i].AbsoluteFee + txsPerGroup[groupID]++ + } + } + // Calculate the average fee based on how many txs have each group + for groupID := range groupAverageFee { + groupAverageFee[groupID] = groupAverageFee[groupID] / float64(txsPerGroup[groupID]) + } + return groupAverageFee +} + +func setInfoForFailedAtomicTx( + isOriginOfFailure bool, + failedAtomicGroupID common.AtomicGroupID, + failedTxID common.TxID, + failMessage common.TxSelectorError, +) common.TxSelectorError { + if isOriginOfFailure { + obj := common.TxSelectorError{ + Message: fmt.Sprintf("unselectable atomic group"+" %s, tx %s failed due to: %s", + failedAtomicGroupID, + failedTxID, + failMessage.Message, + ), + Code: failMessage.Code, + Type: failMessage.Type, + } + return obj } - return l2TxsForgable, l2TxsNonForgable + return common.TxSelectorError{} } diff --git a/txselector/txselector_test.go b/txselector/txselector_test.go index 8454c9bd3..3b7bf5ef7 100644 --- a/txselector/txselector_test.go +++ b/txselector/txselector_test.go @@ -3,6 +3,7 @@ package txselector import ( "fmt" "io/ioutil" + "math/big" "os" "strconv" "testing" @@ -704,8 +705,8 @@ func TestPoolL2TxInvalidNonces(t *testing.T) { require.NoError(t, err) require.Equal(t, 3, len(oL1UserTxs)) require.Equal(t, 0, len(oL1CoordTxs)) - require.Equal(t, 0, len(oL2Txs)) - require.Equal(t, 10, len(discardedL2Txs)) + require.Equal(t, 2, len(oL2Txs)) + require.Equal(t, 8, len(discardedL2Txs)) require.Equal(t, 0, len(accAuths)) err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs), @@ -720,7 +721,7 @@ func TestPoolL2TxInvalidNonces(t *testing.T) { require.Equal(t, 0, len(oL1UserTxs)) require.Equal(t, 3, len(oL1CoordTxs)) - require.Equal(t, 8, len(oL2Txs)) + require.Equal(t, 6, len(oL2Txs)) require.Equal(t, 2, len(discardedL2Txs)) require.Equal(t, 3, len(accAuths)) @@ -816,8 +817,12 @@ func TestProcessL2Selection(t *testing.T) { assert.Equal(t, common.Nonce(2), discardedL2Txs[1].Nonce) assert.Equal(t, "Tx not selected due to not enough Balance at the sender. "+ "Current sender account Balance: 7, Amount+Fee: 11", discardedL2Txs[0].Info) - assert.Equal(t, "Tx not selected due to not current Nonce. Tx.Nonce: 2, "+ - "Account.Nonce: 1", discardedL2Txs[1].Info) + assert.Equal(t, 11, discardedL2Txs[0].ErrorCode) + assert.Equal(t, "ErrSenderNotEnoughBalance", discardedL2Txs[0].ErrorType) + assert.Equal(t, "Tx not selected due to not current Nonce. Tx.Nonce: 2, Account.Nonce: 1", + discardedL2Txs[1].Info) + assert.Equal(t, 12, discardedL2Txs[1].ErrorCode) + assert.Equal(t, "ErrNoCurrentNonce", discardedL2Txs[1].ErrorType) err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs), txsel.localAccountsDB.CurrentBatch()) @@ -905,6 +910,13 @@ func TestValidTxsWithLowFeeAndInvalidTxsWithHighFee(t *testing.T) { // not be included as will be processed first when there is not enough // balance at B (processed first as the TxSelector sorts by Fee and then // by Nonce). + // TODO: The explanation of the test just above is outdated, as the new itereation of txselector + // is capable of detecting more complicated situations. Before merging to develop the explanation + // should be updated. Leaving like this to remember that we have altered the original test, since the + // code is not stable yet, is good to remember of this test modification. The correctness of the result + // has been checked by forging more batches in the original code, and ensuring that the order of the L2Tx + // is the same, but contained in less batches. Also the limits in terms of MaxTxs and MaxL1Tx can be checked by + // comparing the configuration and the asserts batchPoolL2 := ` Type: PoolL2 PoolTransfer(0) B-A: 40 (130) // B-A txs are only possible once A-B txs are processed @@ -931,8 +943,8 @@ func TestValidTxsWithLowFeeAndInvalidTxsWithHighFee(t *testing.T) { require.Equal(t, 0, len(oL1UserTxs)) require.Equal(t, 0, len(oL1CoordTxs)) - require.Equal(t, 3, len(oL2Txs)) // the 3 txs A-B - require.Equal(t, 8, len(discardedL2Txs)) // the 8 txs B-A + require.Equal(t, 5, len(oL2Txs)) // the 3 txs A-B + require.Equal(t, 6, len(discardedL2Txs)) // the 8 txs B-A require.Equal(t, 0, len(accAuths)) err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs), @@ -947,7 +959,7 @@ func TestValidTxsWithLowFeeAndInvalidTxsWithHighFee(t *testing.T) { require.Equal(t, 0, len(oL1UserTxs)) require.Equal(t, 0, len(oL1CoordTxs)) require.Equal(t, 5, len(oL2Txs)) - require.Equal(t, 3, len(discardedL2Txs)) + require.Equal(t, 1, len(discardedL2Txs)) require.Equal(t, 0, len(accAuths)) stateDB.Close() @@ -1021,11 +1033,12 @@ func TestL1UserFutureTxs(t *testing.T) { // despite that there is an AccountCreationAuth for Account B. assert.Equal(t, 0, len(oL2Txs)) assert.Equal(t, 1, len(discardedL2Txs)) - assert.Equal(t, "Tx not selected (in processTxToEthAddrBJJ) due to L2Tx"+ - " discarded at the current batch, as the receiver account does"+ - " not exist yet, and there is a L1UserTx that will create that"+ - " account in a future batch.", + assert.Equal(t, "Tx not selected (in processTxToEthAddrBJJ) due to "+ + "L2Tx discarded at the current batch, as the receiver account does not exist yet, "+ + "and there is a L1UserTx that will create that account in a future batch.", discardedL2Txs[0].Info) + assert.Equal(t, 14, discardedL2Txs[0].ErrorCode) + assert.Equal(t, "ErrTxDiscartedInProcessTxToEthAddrBJJ", discardedL2Txs[0].ErrorType) err = txsel.l2db.StartForging(common.TxIDsFromPoolL2Txs(oL2Txs), txsel.localAccountsDB.CurrentBatch()) @@ -1065,3 +1078,912 @@ func TestL1UserFutureTxs(t *testing.T) { stateDB.Close() txsel.LocalAccountsDB().Close() } + +func TestSimpleAtomicTx(t *testing.T) { + // This test will perform the most simple atomic tx case: + // 1. Create three accounts (with deposit) for the same token: one for coordinator and two for users + // 2. Each account will do a transfer to the other account and request the other tx. + // AccountA does tx 1 to AccountB requesting tx 2. AccountB does tx 2 to AccountA requesting tx 1. + + // Use til to create the account deposits + chainID := uint16(0) + tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx) + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) Coord: 1000 + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, _, _ := initTest(t, chainID, hermezContractAddr, tc.Users["Coord"]) + + tpc := txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 10, + MaxTx: 20, + MaxL1Tx: 10, + ChainID: chainID, + } + + // Forge the 3 first batches, to reach the point were accounts are created + log.Debug("block:0 batch:1") + l1UserTxs := []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(1), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:2") + l1UserTxs = []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(2), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:3") + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum]) + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 3, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(3), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(258), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1000") + checkBalance(t, tc, txsel, "A", 0, "500") + checkBalance(t, tc, txsel, "B", 0, "300") + + // Generate the simple atomic txs + agid := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + // Tx1 fields + tx1 := common.PoolL2Tx{ + FromIdx: 257, // account A + ToIdx: 258, // account B + TokenID: 0, + Amount: big.NewInt(100), + Fee: 0, + Nonce: 0, + RqOffset: 1, // Request tx bellow (position +1) + AtomicGroupID: agid, + RqFromIdx: 258, // account B + RqToIdx: 257, // account A + RqTokenID: 0, + RqAmount: big.NewInt(200), + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + } + // Tx1 signature + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(chainID) + require.NoError(t, err) + accAWallet := til.NewUser(2, "A") + tx1.Signature = accAWallet.BJJ.SignPoseidon(hashTx1).Compress() + // Tx2 fields + tx2 := common.PoolL2Tx{ + FromIdx: 258, // account B + ToIdx: 257, // account A + TokenID: 0, + Amount: big.NewInt(200), + Fee: 0, + Nonce: 0, + RqOffset: 7, // Request tx above (position -1) + AtomicGroupID: agid, + RqFromIdx: 257, // account A + RqToIdx: 258, // account B + RqTokenID: 0, + RqAmount: big.NewInt(100), + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + } + // Tx2 signature + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(chainID) + require.NoError(t, err) + accBWallet := til.NewUser(3, "B") + tx2.Signature = accBWallet.BJJ.SignPoseidon(hashTx2).Compress() + + // Add txs to the pool + addL2Txs(t, txsel, []common.PoolL2Tx{tx1, tx2}) + + log.Debug("block:1 batch:4") + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, nil, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 2, len(oL2Txs)) + assert.Equal(t, common.BatchNum(4), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(258), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1000") + checkBalance(t, tc, txsel, "A", 0, "600") // 500 -100 +200 + checkBalance(t, tc, txsel, "B", 0, "200") // 300 +100 -200 +} + +func TestFailingAtomicTx(t *testing.T) { + // This test will atempt to select an atomic group, which will be rejected due to insufficient balance: + // 1. Create four accounts (with deposit) for the same token: one for coordinator and three for users + // 2. Account A and B will atempt to do an atomic tx, first tx will be valid, but the 2nd won't have enough funds. + // Account C will send a transfer to account Coord, just to check that even with invalid atomic txs, the batch can still forge valid txs + + // Use til to create the account deposits + chainID := uint16(0) + tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx) + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) Coord: 1000 + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + CreateAccountDeposit(0) C: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, _, _ := initTest(t, chainID, hermezContractAddr, tc.Users["Coord"]) + + tpc := txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 10, + MaxTx: 20, + MaxL1Tx: 10, + ChainID: chainID, + } + + // Forge the 3 first batches, to reach the point were accounts are created + log.Debug("block:0 batch:1") + l1UserTxs := []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(1), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:2") + l1UserTxs = []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(2), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:3") + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum]) + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 4, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(3), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(259), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1000") + checkBalance(t, tc, txsel, "A", 0, "500") + checkBalance(t, tc, txsel, "B", 0, "300") + checkBalance(t, tc, txsel, "C", 0, "300") + + // Generate the failing atomic txs + one simple valid tx + agid := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + // Tx1 fields + tx1 := common.PoolL2Tx{ + FromIdx: 257, // account A (balance 500) + ToIdx: 258, // account B + TokenID: 0, + Amount: big.NewInt(50), // Ok + Fee: 0, + Nonce: 0, + RqOffset: 1, // Request tx bellow (position +1) + AtomicGroupID: agid, + RqFromIdx: 258, // account B + RqToIdx: 257, // account A + RqTokenID: 0, + RqAmount: big.NewInt(400), + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + } + // Tx1 signature + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(chainID) + require.NoError(t, err) + accAWallet := til.NewUser(2, "A") + tx1.Signature = accAWallet.BJJ.SignPoseidon(hashTx1).Compress() + // Tx2 fields + tx2 := common.PoolL2Tx{ + FromIdx: 258, // account B (balance 350, as the previous tx will be already processed) + ToIdx: 257, // account A + TokenID: 0, + Amount: big.NewInt(400), + Fee: 0, + Nonce: 0, + RqOffset: 7, // Request tx above (position -1) + AtomicGroupID: agid, + RqFromIdx: 257, // account A + RqToIdx: 258, // account B + RqTokenID: 0, + RqAmount: big.NewInt(50), // OK + RqFee: 0, + RqNonce: 0, + State: common.PoolL2TxStatePending, + } + // Tx2 signature + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(chainID) + require.NoError(t, err) + accBWallet := til.NewUser(3, "B") + tx2.Signature = accBWallet.BJJ.SignPoseidon(hashTx2).Compress() + // Tx3 fields + tx3 := common.PoolL2Tx{ + FromIdx: 259, // account C + ToIdx: 256, // account Coord + TokenID: 0, + Amount: big.NewInt(10), + Fee: 0, + Nonce: 0, + State: common.PoolL2TxStatePending, + } + // Tx3 signature + _, err = common.NewPoolL2Tx(&tx3) + require.NoError(t, err) + hashTx3, err := tx3.HashToSign(chainID) + require.NoError(t, err) + accCWallet := til.NewUser(4, "C") + tx3.Signature = accCWallet.BJJ.SignPoseidon(hashTx3).Compress() + + // Add txs to the pool + addL2Txs(t, txsel, []common.PoolL2Tx{tx1, tx2, tx3}) + + log.Debug("block:1 batch:4") + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, discardedL2Txs, err := + txsel.GetL1L2TxSelection(tpc, nil, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 1, len(oL2Txs)) + assert.Equal(t, 2, len(discardedL2Txs)) + assert.Equal(t, common.BatchNum(4), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(259), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1010") // 1000 + 10 + checkBalance(t, tc, txsel, "A", 0, "500") // Balance not affected due to rejected atomic txs + checkBalance(t, tc, txsel, "B", 0, "300") // Balance not affected due to rejected atomic txs + checkBalance(t, tc, txsel, "C", 0, "290") // 300 - 10 +} + +func TestFilterMaxNumBatch(t *testing.T) { + // This test will check that txs are rejected if MaxNumBatch is exceeded + + // Use til to create the account deposits + chainID := uint16(0) + tc := til.NewContext(chainID, common.RollupConstMaxL1UserTx) + blocks, err := tc.GenerateBlocks(` + Type: Blockchain + > batch + CreateAccountDeposit(0) Coord: 1000 + CreateAccountDeposit(0) A: 500 + CreateAccountDeposit(0) B: 300 + > batchL1 + > batchL1 + > batchL1 + > block + `) + require.NoError(t, err) + + hermezContractAddr := ethCommon.HexToAddress("0xc344E203a046Da13b0B4467EB7B3629D0C99F6E6") + txsel, _, _ := initTest(t, chainID, hermezContractAddr, tc.Users["Coord"]) + + tpc := txprocessor.Config{ + NLevels: 16, + MaxFeeTx: 10, + MaxTx: 20, + MaxL1Tx: 10, + ChainID: chainID, + } + + // Forge the 3 first batches, to reach the point were accounts are created + log.Debug("block:0 batch:1") + l1UserTxs := []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err := + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(1), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:2") + l1UserTxs = []common.L1Tx{} + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(2), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(255), txsel.localAccountsDB.CurrentIdx()) + + log.Debug("block:0 batch:3") + l1UserTxs = til.L1TxsToCommonL1Txs(tc.Queues[*blocks[0].Rollup.Batches[2].Batch.ForgeL1TxsNum]) + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, _, err = + txsel.GetL1L2TxSelection(tpc, l1UserTxs, nil) + require.NoError(t, err) + assert.Equal(t, 3, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 0, len(oL2Txs)) + assert.Equal(t, common.BatchNum(3), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(258), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1000") + checkBalance(t, tc, txsel, "A", 0, "500") + checkBalance(t, tc, txsel, "B", 0, "300") + + // Tx1 fields (this tx won't be processed due to MaxNumBatch > current batch num) + tx1 := common.PoolL2Tx{ + FromIdx: 257, // account A + ToIdx: 258, // account B + TokenID: 0, + Amount: big.NewInt(100), + Fee: 0, + Nonce: 0, + MaxNumBatch: 3, + State: common.PoolL2TxStatePending, + } + // Tx1 signature + _, err = common.NewPoolL2Tx(&tx1) + require.NoError(t, err) + hashTx1, err := tx1.HashToSign(chainID) + require.NoError(t, err) + accAWallet := til.NewUser(2, "A") + tx1.Signature = accAWallet.BJJ.SignPoseidon(hashTx1).Compress() + // Tx2 fields + tx2 := common.PoolL2Tx{ + FromIdx: 258, // account B + ToIdx: 257, // account A + TokenID: 0, + Amount: big.NewInt(200), + Fee: 0, + Nonce: 0, + MaxNumBatch: 4, + State: common.PoolL2TxStatePending, + } + // Tx2 signature + _, err = common.NewPoolL2Tx(&tx2) + require.NoError(t, err) + hashTx2, err := tx2.HashToSign(chainID) + require.NoError(t, err) + accBWallet := til.NewUser(3, "B") + tx2.Signature = accBWallet.BJJ.SignPoseidon(hashTx2).Compress() + + // Add txs to the pool + addL2Txs(t, txsel, []common.PoolL2Tx{tx1, tx2}) + + log.Debug("block:1 batch:4") + _, _, oL1UserTxs, oL1CoordTxs, oL2Txs, discardedL2Txs, err := + txsel.GetL1L2TxSelection(tpc, nil, nil) + require.NoError(t, err) + assert.Equal(t, 0, len(oL1UserTxs)) + assert.Equal(t, 0, len(oL1CoordTxs)) + assert.Equal(t, 1, len(oL2Txs)) + assert.Equal(t, 1, len(discardedL2Txs)) + assert.Equal(t, "MaxNumBatch exceeded", discardedL2Txs[0].Info) + assert.Equal(t, 2, discardedL2Txs[0].ErrorCode) + assert.Equal(t, "ErrUnsupportedMaxNumBatch", discardedL2Txs[0].ErrorType) + assert.Equal(t, common.BatchNum(4), txsel.localAccountsDB.CurrentBatch()) + assert.Equal(t, common.Idx(258), txsel.localAccountsDB.CurrentIdx()) + checkBalance(t, tc, txsel, "Coord", 0, "1000") + checkBalance(t, tc, txsel, "A", 0, "700") // 500 +200 + checkBalance(t, tc, txsel, "B", 0, "100") // 300 -200 +} + +func TestFilterFailedAtomicGroups(t *testing.T) { + // Helper function to perform asserts + assertResult := func( + t *testing.T, + expectedSelectedTxIDs, expectedFilteredTxIDs []common.TxID, + actualSelected, actualFiltered []common.PoolL2Tx, + ) { + // Check if expected and actual have the same amount of items + assert.Equal(t, len(expectedSelectedTxIDs), len(actualSelected)) + assert.Equal(t, len(expectedFilteredTxIDs), len(actualFiltered)) + // Check if the TxIDs of the slected txs much the expectations + for i, txID := range expectedSelectedTxIDs { + assert.Equal(t, txID, actualSelected[i].TxID) + } + // Check if the TxIDs of the slected txs much the expectations + for i, txID := range expectedFilteredTxIDs { + assert.Equal(t, txID, actualFiltered[i].TxID) + } + } + // TxIDs + id1 := common.TxID([common.TxIDLen]byte{1}) + id2 := common.TxID([common.TxIDLen]byte{2}) + id3 := common.TxID([common.TxIDLen]byte{3}) + // AtomicGroupIDs + agid1 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + agid2 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{2}) + + // Case no failing groups + txs := []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid1, + }, + { + TxID: id2, + AtomicGroupID: common.EmptyAtomicGroupID, + }, + } + failedGroups := []failedAtomicGroup{} + selected, filtered := filterFailedAtomicGroups(txs, failedGroups) + assertResult(t, []common.TxID{id1, id2}, nil, selected, filtered) + // Case all failing + txs = []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid1, + }, + { + TxID: id2, + AtomicGroupID: agid2, + }, + } + failedGroups = []failedAtomicGroup{{id: agid1}, {id: agid2}} + selected, filtered = filterFailedAtomicGroups(txs, failedGroups) + assertResult(t, nil, []common.TxID{id1, id2}, selected, filtered) + // Case mixed + txs = []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: common.EmptyAtomicGroupID, + }, + { + TxID: id2, + AtomicGroupID: agid1, + }, + { + TxID: id3, + AtomicGroupID: agid2, + }, + } + failedGroups = []failedAtomicGroup{{id: agid1}} + selected, filtered = filterFailedAtomicGroups(txs, failedGroups) + assertResult(t, []common.TxID{id1, id3}, []common.TxID{id2}, selected, filtered) +} + +func TestCalculateAtomicGroupsAverageFee(t *testing.T) { + // AtomicGroupIDs + agid1 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + agid2 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{2}) + agid3 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{3}) + // Case no atomic groups + txs := []common.PoolL2Tx{ + { + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 1234.567, + }, + } + expected := make(map[common.AtomicGroupID]float64) + actual := calculateAtomicGroupsAverageFee(txs) + assert.Equal(t, expected, actual) + // Case 3 ordered groups + txs = []common.PoolL2Tx{ + { + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 1234.567, + }, + { + AtomicGroupID: agid1, + AbsoluteFee: 1.0, + }, + { + AtomicGroupID: agid2, + AbsoluteFee: 2.0, + }, + { + AtomicGroupID: agid2, + AbsoluteFee: 2.0, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + } + expected = make(map[common.AtomicGroupID]float64) + expected[agid1] = 1.0 + expected[agid2] = (2.0 + 2.0) / 2 + expected[agid3] = (3.0 + 3.0 + 3.0) / 3 + actual = calculateAtomicGroupsAverageFee(txs) + assert.Equal(t, expected, actual) + // Case 3 not ordered groups + txs = []common.PoolL2Tx{ + { + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 1234.567, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + { + AtomicGroupID: agid2, + AbsoluteFee: 2.0, + }, + { + AtomicGroupID: agid2, + AbsoluteFee: 2.0, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + { + AtomicGroupID: agid3, + AbsoluteFee: 3.0, + }, + { + AtomicGroupID: agid1, + AbsoluteFee: 1.0, + }, + } + expected = make(map[common.AtomicGroupID]float64) + expected[agid1] = 1.0 + expected[agid2] = (2.0 + 2.0) / 2 + expected[agid3] = (3.0 + 3.0 + 3.0) / 3 + actual = calculateAtomicGroupsAverageFee(txs) + assert.Equal(t, expected, actual) +} + +func TestSortL2Txs(t *testing.T) { + // Helper function to perform asserts + assertResult := func(t *testing.T, expected []common.TxID, actual []common.PoolL2Tx) { + assert.Equal(t, len(expected), len(actual)) + for i, a := range actual { + assert.Equal(t, expected[i], a.TxID) + } + } + // TxIDs + id1 := common.TxID([common.TxIDLen]byte{1}) + id2 := common.TxID([common.TxIDLen]byte{2}) + id3 := common.TxID([common.TxIDLen]byte{3}) + id4 := common.TxID([common.TxIDLen]byte{4}) + id5 := common.TxID([common.TxIDLen]byte{5}) + id6 := common.TxID([common.TxIDLen]byte{6}) + id7 := common.TxID([common.TxIDLen]byte{7}) + + // AtomicGroupIDs + agid1 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + agid2 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{2}) + // Case only non atomic + txs := []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 3, + Nonce: 2, + }, + { + TxID: id2, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 3, + Nonce: 1, + }, + { + TxID: id3, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 7, + Nonce: 2, + }, + } + fees := calculateAtomicGroupsAverageFee(txs) + actual := sortL2Txs(txs, fees) + assertResult(t, []common.TxID{id2, id3, id1}, actual) + // Case only atomic + txs = []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid2, + AbsoluteFee: 3, + Nonce: 2220, + }, + { + TxID: id2, + AtomicGroupID: agid2, + AbsoluteFee: 3, + Nonce: 1, + }, + { + TxID: id3, + AtomicGroupID: agid1, + AbsoluteFee: 7, + Nonce: 300, + }, + { + TxID: id4, + AtomicGroupID: agid1, + AbsoluteFee: 700, + Nonce: 2, + }, + } + fees = calculateAtomicGroupsAverageFee(txs) + actual = sortL2Txs(txs, fees) + assertResult(t, []common.TxID{id3, id4, id1, id2}, actual) + // Case mixed + txs = []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid2, + AbsoluteFee: 20, + Nonce: 2220, + }, + { + TxID: id2, + AtomicGroupID: agid2, + AbsoluteFee: 20, + Nonce: 1, + }, + { + TxID: id3, + AtomicGroupID: agid1, + AbsoluteFee: 30, + Nonce: 300, + }, + { + TxID: id4, + AtomicGroupID: agid1, + AbsoluteFee: 30, + Nonce: 2, + }, + { + TxID: id5, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 25, + Nonce: 2, + }, + { + TxID: id6, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 10, + Nonce: 2, + }, + { + TxID: id7, + AtomicGroupID: common.EmptyAtomicGroupID, + AbsoluteFee: 35, + Nonce: 2, + }, + } + fees = calculateAtomicGroupsAverageFee(txs) + actual = sortL2Txs(txs, fees) + assertResult(t, []common.TxID{id7, id3, id4, id5, id1, id2, id6}, actual) +} + +func TestFilterInvalidAtomicGroups(t *testing.T) { + // TxIDs + id1 := common.TxID([common.TxIDLen]byte{1}) + id2 := common.TxID([common.TxIDLen]byte{2}) + id3 := common.TxID([common.TxIDLen]byte{3}) + id4 := common.TxID([common.TxIDLen]byte{4}) + id5 := common.TxID([common.TxIDLen]byte{5}) + id6 := common.TxID([common.TxIDLen]byte{6}) + id7 := common.TxID([common.TxIDLen]byte{7}) + id8 := common.TxID([common.TxIDLen]byte{8}) + id9 := common.TxID([common.TxIDLen]byte{9}) + id10 := common.TxID([common.TxIDLen]byte{10}) + id11 := common.TxID([common.TxIDLen]byte{11}) + id12 := common.TxID([common.TxIDLen]byte{12}) + // AtomicGroupIDs + agid1 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{1}) + agid2 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{2}) + agid3 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{3}) + agid4 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{4}) + agid5 := common.AtomicGroupID([common.AtomicGroupIDLen]byte{5}) + // Helper to check result + assertIds := func(t *testing.T, expected []common.TxID, actual []common.PoolL2Tx) { + // Check 1: same amount of expected vs actual + require.Equal(t, len(expected), len(actual)) + // Check 2: expected and actual have the same items (but maybe different order) + for _, id := range expected { + found := false + for _, tx := range actual { + if id == tx.TxID { + found = true + break + } + } + assert.True(t, found) + } + // Check 3: order is preserved within atomic groups + // Create atomic groups + atomicGroups := make(map[common.AtomicGroupID]common.AtomicGroup) + for i := range actual { + atomicGroupID := actual[i].AtomicGroupID + if atomicGroupID == common.EmptyAtomicGroupID { + continue + } + if atomicGroup, ok := atomicGroups[atomicGroupID]; !ok { + atomicGroups[atomicGroupID] = common.AtomicGroup{ + Txs: []common.PoolL2Tx{actual[i]}, + } + } else { + atomicGroup.Txs = append(atomicGroup.Txs, actual[i]) + atomicGroups[atomicGroupID] = atomicGroup + } + } + for _, atomicGroup := range atomicGroups { + var firstPositionInExpected int + for j := range expected { + if expected[j] == atomicGroup.Txs[0].TxID { + firstPositionInExpected = j + break + } + } + for i, tx := range atomicGroup.Txs { + assert.Equal(t, expected[firstPositionInExpected+i], tx.TxID) + } + } + } + + // All groups invalid + txs := []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid1, + RqOffset: 1, + }, + { + TxID: id2, + AtomicGroupID: agid1, + RqOffset: 7, + RqFromIdx: 777, // Missmatch of RqFromIdx + }, + { + TxID: id3, + }, + { + TxID: id4, + AtomicGroupID: agid2, + RqOffset: 1, + }, + { + TxID: id5, + AtomicGroupID: agid2, + RqOffset: 7, + RqAmount: big.NewInt(7), // Missmatch of RqFromIdx + }, + { + TxID: id6, + AtomicGroupID: agid3, + RqOffset: 1, + }, + { + TxID: id7, + AtomicGroupID: agid3, + RqOffset: 5, // Invalid RqOffset + }, + { + TxID: id8, + }, + { + TxID: id9, + AtomicGroupID: agid4, + RqOffset: 1, + }, + { + TxID: id10, + }, + { + TxID: id11, + AtomicGroupID: agid5, + RqOffset: 1, + Fee: 123, + }, + { + TxID: id12, + AtomicGroupID: agid5, + RqOffset: 7, + }, + } + valid, invalid := filterInvalidAtomicGroups(txs) + assertIds(t, []common.TxID{id3, id8, id10}, valid) + assertIds(t, []common.TxID{id1, id2, id4, id5, id6, id7, id9, id11, id12}, invalid) + // All groups valid + txs = []common.PoolL2Tx{ + { + TxID: id1, + AtomicGroupID: agid1, + RqOffset: 1, + }, + { + TxID: id2, + AtomicGroupID: agid1, + RqOffset: 7, + }, + { + TxID: id3, + }, + { + TxID: id4, + AtomicGroupID: agid2, + RqOffset: 1, + }, + { + TxID: id5, + AtomicGroupID: agid2, + RqOffset: 7, + }, + { + TxID: id6, + AtomicGroupID: agid3, + RqOffset: 1, + }, + { + TxID: id7, + AtomicGroupID: agid3, + RqOffset: 7, + }, + { + TxID: id8, + }, + { + TxID: id9, + AtomicGroupID: agid4, + RqOffset: 1, + }, + { + TxID: id10, + AtomicGroupID: agid4, + RqOffset: 7, + }, + { + TxID: id11, + AtomicGroupID: agid5, + RqOffset: 1, + }, + { + TxID: id12, + AtomicGroupID: agid5, + RqOffset: 7, + }, + } + valid, invalid = filterInvalidAtomicGroups(txs) + assertIds(t, []common.TxID{id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12}, valid) + assertIds(t, []common.TxID{}, invalid) +}