From 21cb21ba5781bdf416ae09ca61d82172565c3f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Fri, 2 Feb 2024 10:46:56 +0100 Subject: [PATCH 01/12] Make client validator methods handle pages --- components/restapi/core/accounts.go | 13 ++++++------- pkg/restapi/restapi.go | 27 --------------------------- 2 files changed, 6 insertions(+), 34 deletions(-) delete mode 100644 pkg/restapi/restapi.go diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index 1d086b3d6..8633beb38 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -11,7 +11,6 @@ import ( "github.com/iotaledger/inx-app/pkg/httpserver" "github.com/iotaledger/iota-core/components/restapi" "github.com/iotaledger/iota-core/pkg/core/account" - restapipkg "github.com/iotaledger/iota-core/pkg/restapi" iotago "github.com/iotaledger/iota.go/v4" "github.com/iotaledger/iota.go/v4/api" ) @@ -62,10 +61,10 @@ func congestionByAccountAddress(c echo.Context) (*api.CongestionResponse, error) func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error pageSize := restapi.ParamsRestAPI.MaxPageSize - if len(c.QueryParam(restapipkg.QueryParameterPageSize)) > 0 { - pageSize, err = httpserver.ParseUint32QueryParam(c, restapipkg.QueryParameterPageSize) + if len(c.QueryParam(api.QueryParameterPageSize)) > 0 { + pageSize, err = httpserver.ParseUint32QueryParam(c, api.QueryParameterPageSize) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse page size %s", c.Param(restapipkg.QueryParameterPageSize)) + return nil, ierrors.Wrapf(err, "failed to parse page size %s", c.Param(api.QueryParameterPageSize)) } if pageSize > restapi.ParamsRestAPI.MaxPageSize { pageSize = restapi.ParamsRestAPI.MaxPageSize @@ -75,10 +74,10 @@ func validators(c echo.Context) (*api.ValidatorsResponse, error) { // no cursor provided will be the first request requestedSlot := latestCommittedSlot var cursorIndex uint32 - if len(c.QueryParam(restapipkg.QueryParameterCursor)) != 0 { - requestedSlot, cursorIndex, err = httpserver.ParseCursorQueryParam(c, restapipkg.QueryParameterCursor) + if len(c.QueryParam(api.QueryParameterCursor)) != 0 { + requestedSlot, cursorIndex, err = httpserver.ParseCursorQueryParam(c, api.QueryParameterCursor) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse cursor %s", c.Param(restapipkg.QueryParameterCursor)) + return nil, ierrors.Wrapf(err, "failed to parse cursor %s", c.Param(api.QueryParameterCursor)) } } diff --git a/pkg/restapi/restapi.go b/pkg/restapi/restapi.go deleted file mode 100644 index 39afa8b29..000000000 --- a/pkg/restapi/restapi.go +++ /dev/null @@ -1,27 +0,0 @@ -package restapi - -import ( - "github.com/labstack/echo/v4" - "github.com/libp2p/go-libp2p/core/peer" - - "github.com/iotaledger/hive.go/ierrors" - "github.com/iotaledger/inx-app/pkg/httpserver" - "github.com/iotaledger/iota.go/v4/api" -) - -const ( - // QueryParameterPageSize is used to specify the page size. - QueryParameterPageSize = "pageSize" - - // QueryParameterCursor is used to specify the the point from which the response should continue for paginater results. - QueryParameterCursor = "cursor" -) - -func ParsePeerIDParam(c echo.Context) (peer.ID, error) { - peerID, err := peer.Decode(c.Param(api.ParameterPeerID)) - if err != nil { - return "", ierrors.Wrapf(httpserver.ErrInvalidParameter, "invalid peerID, error: %s", err) - } - - return peerID, nil -} From e150a1c08208d4916b9a2bca23a14f5e9f1ce0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 12:40:12 +0100 Subject: [PATCH 02/12] Update iotago --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b16b1eef5..b54e2206b 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240125161730-faf053c90f7b github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 - github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 + github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 github.com/labstack/echo/v4 v4.11.4 github.com/labstack/gommon v0.4.2 github.com/libp2p/go-libp2p v0.32.2 diff --git a/go.sum b/go.sum index 6d6475af2..9673927a0 100644 --- a/go.sum +++ b/go.sum @@ -309,8 +309,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 h1:Z7twy8 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506/go.mod h1:x8dn1yT4TtyucfQz1Qb4LrqjdxmOMy7oiRiVedLD2/s= github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4= github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0= -github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 h1:p/Ytvv+wlnj5UNd1vdKT4BFS9o63sicb8HVC4XleUUI= -github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 h1:p+0GJo3nAoi2h5V6d6x6vt44vI2Zj/y4zQVz7TtlA2s= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= github.com/ipfs/boxo v0.17.0 h1:fVXAb12dNbraCX1Cdid5BB6Kl62gVLNVA+e0EYMqAU0= github.com/ipfs/boxo v0.17.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= From bbab274935b0033bfe7ba53025c5ab52572b6904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 12:53:46 +0100 Subject: [PATCH 03/12] Update iotago for tools --- tools/gendoc/go.mod | 2 +- tools/gendoc/go.sum | 2 ++ tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/gendoc/go.mod b/tools/gendoc/go.mod index 490af8b7b..ca3353b5b 100644 --- a/tools/gendoc/go.mod +++ b/tools/gendoc/go.mod @@ -71,7 +71,7 @@ require ( github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240125161730-faf053c90f7b // indirect github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 // indirect github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 // indirect - github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 // indirect + github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 // indirect github.com/ipfs/boxo v0.17.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/ipfs/go-datastore v0.6.0 // indirect diff --git a/tools/gendoc/go.sum b/tools/gendoc/go.sum index 793615c04..5bbb31957 100644 --- a/tools/gendoc/go.sum +++ b/tools/gendoc/go.sum @@ -315,6 +315,8 @@ github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5u github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0= github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 h1:p/Ytvv+wlnj5UNd1vdKT4BFS9o63sicb8HVC4XleUUI= github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 h1:p+0GJo3nAoi2h5V6d6x6vt44vI2Zj/y4zQVz7TtlA2s= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= github.com/ipfs/boxo v0.17.0 h1:fVXAb12dNbraCX1Cdid5BB6Kl62gVLNVA+e0EYMqAU0= github.com/ipfs/boxo v0.17.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index 3ef54e5be..c45e2f8e9 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/hive.go/runtime v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 + github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.18.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index b5f0894af..d1fab6ed1 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -56,6 +56,8 @@ github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5u github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0= github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914 h1:p/Ytvv+wlnj5UNd1vdKT4BFS9o63sicb8HVC4XleUUI= github.com/iotaledger/iota.go/v4 v4.0.0-20240125151023-8623fbbce914/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4 h1:p+0GJo3nAoi2h5V6d6x6vt44vI2Zj/y4zQVz7TtlA2s= +github.com/iotaledger/iota.go/v4 v4.0.0-20240202111251-e3c83fac64c4/go.mod h1:GNDWMpc9sO3H2HJQMlGiOpyAAbT9I1kUx+YH6kkmVpY= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= From efe64c2c7ffae9995bb8e80f3c7e3b040038ed54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 16:22:21 +0100 Subject: [PATCH 04/12] Rename and fixes --- components/restapi/core/accounts.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index 8633beb38..f8a874121 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -61,10 +61,10 @@ func congestionByAccountAddress(c echo.Context) (*api.CongestionResponse, error) func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error pageSize := restapi.ParamsRestAPI.MaxPageSize - if len(c.QueryParam(api.QueryParameterPageSize)) > 0 { - pageSize, err = httpserver.ParseUint32QueryParam(c, api.QueryParameterPageSize) + if len(c.QueryParam(api.ParameterPageSize)) > 0 { + pageSize, err = httpserver.ParseUint32QueryParam(c, api.ParameterPageSize) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse page size %s", c.Param(api.QueryParameterPageSize)) + return nil, ierrors.Wrapf(err, "failed to parse page size %s", c.Param(api.ParameterPageSize)) } if pageSize > restapi.ParamsRestAPI.MaxPageSize { pageSize = restapi.ParamsRestAPI.MaxPageSize @@ -74,10 +74,10 @@ func validators(c echo.Context) (*api.ValidatorsResponse, error) { // no cursor provided will be the first request requestedSlot := latestCommittedSlot var cursorIndex uint32 - if len(c.QueryParam(api.QueryParameterCursor)) != 0 { - requestedSlot, cursorIndex, err = httpserver.ParseCursorQueryParam(c, api.QueryParameterCursor) + if len(c.QueryParam(api.ParameterCursor)) != 0 { + requestedSlot, cursorIndex, err = httpserver.ParseCursorQueryParam(c, api.ParameterCursor) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse cursor %s", c.Param(api.QueryParameterCursor)) + return nil, ierrors.Wrapf(err, "failed to parse cursor %s", c.Param(api.ParameterCursor)) } } From e8afd1a06a5fe8849c61d9c6b2a6077fb93e2b1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 16:33:47 +0100 Subject: [PATCH 05/12] Fix getting eligible validators --- .../sybilprotectionv1/sybilprotection.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go index b78003ed9..e8598afaf 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go @@ -332,18 +332,14 @@ func (o *SybilProtection) EligibleValidators(epoch iotago.EpochIndex) (accounts. // OrderedRegisteredCandidateValidatorsList returns the currently known list of registered validator candidates for the given epoch. func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*api.ValidatorResponse, error) { - candidates, err := o.performanceTracker.ValidatorCandidates(epoch) - if err != nil { - return nil, ierrors.Wrapf(err, "failed to retrieve candidates") - } - - activeCandidates, err := o.performanceTracker.EligibleValidatorCandidates(epoch) + // currently we have only active validators list, validators are stored under the epoch of registration, thus we use epoch-1 + activeCandidates, err := o.performanceTracker.EligibleValidatorCandidates(epoch - 1) if err != nil { return nil, ierrors.Wrapf(err, "failed to retrieve eligible candidates") } - validatorResp := make([]*api.ValidatorResponse, 0, candidates.Size()) - if err := candidates.ForEach(func(candidate iotago.AccountID) error { + validatorResp := make([]*api.ValidatorResponse, 0, activeCandidates.Size()) + if err := activeCandidates.ForEach(func(candidate iotago.AccountID) error { accountData, exists, err := o.ledger.Account(candidate, o.lastCommittedSlot) if err != nil { return ierrors.Wrapf(err, "failed to get account %s", candidate) @@ -355,14 +351,13 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago. if accountData.StakeEndEpoch <= epoch { return nil } - active := activeCandidates.Has(candidate) validatorResp = append(validatorResp, &api.ValidatorResponse{ AddressBech32: accountData.ID.ToAddress().Bech32(o.apiProvider.CommittedAPI().ProtocolParameters().Bech32HRP()), StakingEndEpoch: accountData.StakeEndEpoch, PoolStake: accountData.ValidatorStake + accountData.DelegationStake, ValidatorStake: accountData.ValidatorStake, FixedCost: accountData.FixedCost, - Active: active, + Active: true, LatestSupportedProtocolVersion: accountData.LatestSupportedProtocolVersionAndHash.Version, LatestSupportedProtocolHash: accountData.LatestSupportedProtocolVersionAndHash.Hash, }) From bfbbf69fc179c2685f6c40616eec3df048709ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 16:59:42 +0100 Subject: [PATCH 06/12] Use ParsePageSizeParam from httpserver --- components/restapi/core/accounts.go | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index f8a874121..ad4a39200 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -60,16 +60,7 @@ func congestionByAccountAddress(c echo.Context) (*api.CongestionResponse, error) func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error - pageSize := restapi.ParamsRestAPI.MaxPageSize - if len(c.QueryParam(api.ParameterPageSize)) > 0 { - pageSize, err = httpserver.ParseUint32QueryParam(c, api.ParameterPageSize) - if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse page size %s", c.Param(api.ParameterPageSize)) - } - if pageSize > restapi.ParamsRestAPI.MaxPageSize { - pageSize = restapi.ParamsRestAPI.MaxPageSize - } - } + pageSize := httpserver.ParsePageSizeParam(c, api.ParameterPageSize, restapi.ParamsRestAPI.MaxPageSize) latestCommittedSlot := deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot() // no cursor provided will be the first request requestedSlot := latestCommittedSlot From 5787931e14faf81029ab2525c3ae88af820bf1d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 17:06:52 +0100 Subject: [PATCH 07/12] Update iotago and inx-app --- go.mod | 4 ++-- go.sum | 8 ++++---- tools/genesis-snapshot/go.mod | 2 +- tools/genesis-snapshot/go.sum | 2 ++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 1aa889513..3b1992e9b 100644 --- a/go.mod +++ b/go.mod @@ -23,10 +23,10 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240126143305-9caf79103e85 github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85 - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240125161730-faf053c90f7b + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 - github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479 + github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186 github.com/labstack/echo/v4 v4.11.4 github.com/labstack/gommon v0.4.2 github.com/libp2p/go-libp2p v0.32.2 diff --git a/go.sum b/go.sum index 125cf4fe1..cf4482ab8 100644 --- a/go.sum +++ b/go.sum @@ -303,14 +303,14 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240126143305-9caf791 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240126143305-9caf79103e85/go.mod h1:bpJrJ0zYJqHpk8zIB5Sz7r9KCwpgKBaqHby5Uoouipg= github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85 h1:wKzomqZKS4xpefyYOPD9uDqwIz+3UWBRh3SCL2hxEBU= github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240125161730-faf053c90f7b h1:VhO5jTY5hlamUzEUcfFiEaAn5lgVjiySNYM7iOF7BUY= -github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240125161730-faf053c90f7b/go.mod h1:PQBjosLKS1kL1RK2/PYnZxNHf+Co3JrbpBSgViKITEM= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8 h1:/F4PuxM6usti2cgN92nveNKhbPpA+crjsm/kHNWJGNc= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8/go.mod h1:BIZ+v0l16km86aBp66Shhku6Y5FkrCW6yy2TfebPnp0= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 h1:Z7twy8TSuB2Tcjd7pzTtBH3ku90hIMguNSnypswFZyE= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506/go.mod h1:x8dn1yT4TtyucfQz1Qb4LrqjdxmOMy7oiRiVedLD2/s= github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4= github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0= -github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479 h1:YrPVCuzSLUAeewXjip4B3g8WkpVweXDqtZNt3kppaoU= -github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8= +github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186 h1:9N1Mu5rzC9ZNIKNIvigswdX909Jb/IS0YB9wnfAOziY= +github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8= github.com/ipfs/boxo v0.17.0 h1:fVXAb12dNbraCX1Cdid5BB6Kl62gVLNVA+e0EYMqAU0= github.com/ipfs/boxo v0.17.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= diff --git a/tools/genesis-snapshot/go.mod b/tools/genesis-snapshot/go.mod index 2d15212df..4806f3c68 100644 --- a/tools/genesis-snapshot/go.mod +++ b/tools/genesis-snapshot/go.mod @@ -10,7 +10,7 @@ require ( github.com/iotaledger/hive.go/lo v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/hive.go/runtime v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000 - github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479 + github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186 github.com/mr-tron/base58 v1.2.0 github.com/spf13/pflag v1.0.5 golang.org/x/crypto v0.18.0 diff --git a/tools/genesis-snapshot/go.sum b/tools/genesis-snapshot/go.sum index 103e217f8..1e720a0ba 100644 --- a/tools/genesis-snapshot/go.sum +++ b/tools/genesis-snapshot/go.sum @@ -56,6 +56,8 @@ github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5u github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0= github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479 h1:YrPVCuzSLUAeewXjip4B3g8WkpVweXDqtZNt3kppaoU= github.com/iotaledger/iota.go/v4 v4.0.0-20240205131109-72af13887479/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8= +github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186 h1:9N1Mu5rzC9ZNIKNIvigswdX909Jb/IS0YB9wnfAOziY= +github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= From f7d923af32bbdbd5719b73e92e4b5c0d9ddf4e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 17:17:15 +0100 Subject: [PATCH 08/12] Rename --- components/restapi/core/accounts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index ad4a39200..0ce7fcb24 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -60,7 +60,7 @@ func congestionByAccountAddress(c echo.Context) (*api.CongestionResponse, error) func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error - pageSize := httpserver.ParsePageSizeParam(c, api.ParameterPageSize, restapi.ParamsRestAPI.MaxPageSize) + pageSize := httpserver.ParsePageSizeQueryParam(c, api.ParameterPageSize, restapi.ParamsRestAPI.MaxPageSize) latestCommittedSlot := deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot() // no cursor provided will be the first request requestedSlot := latestCommittedSlot From bd4bdb578feea1297a9e9d39cf0b254978ddb18e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daria=20Dziuba=C5=82towska?= Date: Mon, 5 Feb 2024 17:18:53 +0100 Subject: [PATCH 09/12] Update inx-app --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3b1992e9b..7e201ff1a 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/iotaledger/hive.go/runtime v0.0.0-20240126143305-9caf79103e85 github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240126143305-9caf79103e85 github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85 - github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8 + github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205161716-46b8e9baff10 github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 github.com/iotaledger/iota.go/v4 v4.0.0-20240205160134-09a7229d4186 diff --git a/go.sum b/go.sum index cf4482ab8..9824d6d67 100644 --- a/go.sum +++ b/go.sum @@ -305,6 +305,8 @@ github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85 h1:wK github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs= github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8 h1:/F4PuxM6usti2cgN92nveNKhbPpA+crjsm/kHNWJGNc= github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205160142-bd9f1aa5f5b8/go.mod h1:BIZ+v0l16km86aBp66Shhku6Y5FkrCW6yy2TfebPnp0= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205161716-46b8e9baff10 h1:7kTwHtcp2d+hJCtmy3RGMzFD+5YSBOPawHGfcFzk8M0= +github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240205161716-46b8e9baff10/go.mod h1:BIZ+v0l16km86aBp66Shhku6Y5FkrCW6yy2TfebPnp0= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 h1:Z7twy8TSuB2Tcjd7pzTtBH3ku90hIMguNSnypswFZyE= github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506/go.mod h1:x8dn1yT4TtyucfQz1Qb4LrqjdxmOMy7oiRiVedLD2/s= github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4= From 2fe3f9a9e110a3c49cf12166c4e65681f0397416 Mon Sep 17 00:00:00 2001 From: muXxer Date: Tue, 13 Feb 2024 15:23:44 +0100 Subject: [PATCH 10/12] Increase faucet mana limits --- .../templates/docker-compose-iota-core.yml.j2 | 7 +++++-- tools/docker-network/docker-compose.yml | 5 +++++ tools/genesis-snapshot/presets/presets.go | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/deploy/ansible/roles/iota-core-node/templates/docker-compose-iota-core.yml.j2 b/deploy/ansible/roles/iota-core-node/templates/docker-compose-iota-core.yml.j2 index 8bc61f43c..2dbe6841c 100644 --- a/deploy/ansible/roles/iota-core-node/templates/docker-compose-iota-core.yml.j2 +++ b/deploy/ansible/roles/iota-core-node/templates/docker-compose-iota-core.yml.j2 @@ -128,9 +128,12 @@ services: command: > --inx.address=iota-core:9029 --faucet.bindAddress=0.0.0.0:8091 - --faucet.manaAmount=100000000 + --faucet.rateLimit.enabled=true --faucet.baseTokenAmount=1000000000000 - --faucet.baseTokenAmountMaxTarget=100000000000000 + --faucet.baseTokenAmountSmall=100000000000 + --faucet.baseTokenAmountMaxTarget=5000000000000 + --faucet.manaAmount=100000000 + --faucet.manaAmountMinFaucet=1000000000 {% endif %} {% if 'node-01' in inventory_hostname or 'node-02' in inventory_hostname or 'node-03' in inventory_hostname %} diff --git a/tools/docker-network/docker-compose.yml b/tools/docker-network/docker-compose.yml index 536d10a0c..dd128e5bc 100644 --- a/tools/docker-network/docker-compose.yml +++ b/tools/docker-network/docker-compose.yml @@ -282,6 +282,11 @@ services: --inx.address=node-1-validator:9029 --faucet.bindAddress=inx-faucet:8091 --faucet.rateLimit.enabled=false + --faucet.baseTokenAmount=1000000000 + --faucet.baseTokenAmountSmall=100000000 + --faucet.baseTokenAmountMaxTarget=5000000000 + --faucet.manaAmount=10000000 + --faucet.manaAmountMinFaucet=100000000 inx-validator-1: image: iotaledger/inx-validator:1.0-alpha diff --git a/tools/genesis-snapshot/presets/presets.go b/tools/genesis-snapshot/presets/presets.go index 75e9a8ffc..d6392c53c 100644 --- a/tools/genesis-snapshot/presets/presets.go +++ b/tools/genesis-snapshot/presets/presets.go @@ -158,7 +158,7 @@ var ( snapshotcreator.BasicOutputDetails{ Address: lo.Return2(iotago.ParseBech32("rms1xqqz7e8e69uej86s2s4srcp5lgzrkx25qwr4hpnha7h3j66pezyq85qpqg55v3ur")), Amount: 1_000_000_000_000_000, - Mana: 10_000_000, + Mana: 1_000_000_000_000_000, }, ), } @@ -278,7 +278,7 @@ var ( snapshotcreator.BasicOutputDetails{ Address: lo.Return2(iotago.ParseBech32("rms1xqqy3txhvnmzv53kgm2ueu30splfd5ct02cqvnehpdn04qgeskv9a3qpqgrhlhv3")), Amount: 1_000_000_000_000_000, - Mana: 10_000_000, + Mana: 1_000_000_000_000_000, }, ), } From 3d213c98725e71b1635b83b3d694df612d972c6c Mon Sep 17 00:00:00 2001 From: muXxer Date: Tue, 13 Feb 2024 18:44:03 +0100 Subject: [PATCH 11/12] Revert the changes in `OrderedRegisteredCandidateValidatorsList` --- components/restapi/core/accounts.go | 6 ++++-- .../sybilprotectionv1/sybilprotection.go | 15 ++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index 30c354b3c..76af9fc16 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -73,13 +73,14 @@ func validators(c echo.Context) (*api.ValidatorsResponse, error) { var err error pageSize := httpserver.ParsePageSizeQueryParam(c, api.ParameterPageSize, restapi.ParamsRestAPI.MaxPageSize) latestCommittedSlot := deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot() + // no cursor provided will be the first request requestedSlot := latestCommittedSlot var cursorIndex uint32 if len(c.QueryParam(api.ParameterCursor)) != 0 { requestedSlot, cursorIndex, err = httpserver.ParseCursorQueryParam(c, api.ParameterCursor) if err != nil { - return nil, ierrors.Wrapf(err, "failed to parse cursor %s", c.Param(api.ParameterCursor)) + return nil, err } } @@ -93,7 +94,8 @@ func validators(c echo.Context) (*api.ValidatorsResponse, error) { slotRange := uint32(requestedSlot) / restapi.ParamsRestAPI.RequestsMemoryCacheGranularity registeredValidators, exists := deps.Protocol.Engines.Main.Get().Retainer.RegisteredValidatorsCache(slotRange) if !exists { - registeredValidators, err = deps.Protocol.Engines.Main.Get().SybilProtection.OrderedRegisteredCandidateValidatorsList(nextEpoch) + // HINT: the validators for an epoch are stored in the previous epoch + registeredValidators, err = deps.Protocol.Engines.Main.Get().SybilProtection.OrderedRegisteredCandidateValidatorsList(nextEpoch - 1) if err != nil { return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to get ordered registered validators list for epoch %d : %s", nextEpoch, err) } diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go index e8598afaf..b78003ed9 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go @@ -332,14 +332,18 @@ func (o *SybilProtection) EligibleValidators(epoch iotago.EpochIndex) (accounts. // OrderedRegisteredCandidateValidatorsList returns the currently known list of registered validator candidates for the given epoch. func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago.EpochIndex) ([]*api.ValidatorResponse, error) { - // currently we have only active validators list, validators are stored under the epoch of registration, thus we use epoch-1 - activeCandidates, err := o.performanceTracker.EligibleValidatorCandidates(epoch - 1) + candidates, err := o.performanceTracker.ValidatorCandidates(epoch) + if err != nil { + return nil, ierrors.Wrapf(err, "failed to retrieve candidates") + } + + activeCandidates, err := o.performanceTracker.EligibleValidatorCandidates(epoch) if err != nil { return nil, ierrors.Wrapf(err, "failed to retrieve eligible candidates") } - validatorResp := make([]*api.ValidatorResponse, 0, activeCandidates.Size()) - if err := activeCandidates.ForEach(func(candidate iotago.AccountID) error { + validatorResp := make([]*api.ValidatorResponse, 0, candidates.Size()) + if err := candidates.ForEach(func(candidate iotago.AccountID) error { accountData, exists, err := o.ledger.Account(candidate, o.lastCommittedSlot) if err != nil { return ierrors.Wrapf(err, "failed to get account %s", candidate) @@ -351,13 +355,14 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago. if accountData.StakeEndEpoch <= epoch { return nil } + active := activeCandidates.Has(candidate) validatorResp = append(validatorResp, &api.ValidatorResponse{ AddressBech32: accountData.ID.ToAddress().Bech32(o.apiProvider.CommittedAPI().ProtocolParameters().Bech32HRP()), StakingEndEpoch: accountData.StakeEndEpoch, PoolStake: accountData.ValidatorStake + accountData.DelegationStake, ValidatorStake: accountData.ValidatorStake, FixedCost: accountData.FixedCost, - Active: true, + Active: active, LatestSupportedProtocolVersion: accountData.LatestSupportedProtocolVersionAndHash.Version, LatestSupportedProtocolHash: accountData.LatestSupportedProtocolVersionAndHash.Hash, }) From 341a54554459b81557eebad338f995bda1717a71 Mon Sep 17 00:00:00 2001 From: muXxer Date: Wed, 14 Feb 2024 13:15:33 +0100 Subject: [PATCH 12/12] Fix broken error checks --- pkg/protocol/blocks.go | 2 +- pkg/protocol/engine/ledger/ledger/ledger.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/protocol/blocks.go b/pkg/protocol/blocks.go index 414c1262c..479033628 100644 --- a/pkg/protocol/blocks.go +++ b/pkg/protocol/blocks.go @@ -89,7 +89,7 @@ func (b *Blocks) ProcessResponse(block *model.Block, from peer.ID) { b.workerPool.Submit(func() { // abort if the commitment belongs to an evicted slot commitment, err := b.protocol.Commitments.Get(block.ProtocolBlock().Header.SlotCommitmentID, true) - if err != nil && ierrors.Is(ErrorSlotEvicted, err) { + if err != nil && ierrors.Is(err, ErrorSlotEvicted) { b.LogError("dropped block referencing unsolidifiable commitment", "commitmentID", block.ProtocolBlock().Header.SlotCommitmentID, "blockID", block.ID(), "err", err) return diff --git a/pkg/protocol/engine/ledger/ledger/ledger.go b/pkg/protocol/engine/ledger/ledger/ledger.go index df1d5216a..c281951ee 100644 --- a/pkg/protocol/engine/ledger/ledger/ledger.go +++ b/pkg/protocol/engine/ledger/ledger/ledger.go @@ -274,7 +274,7 @@ func (l *Ledger) OutputOrSpent(outputID iotago.OutputID) (*utxoledger.Output, *u stateRef := mempool.UTXOInputStateRefFromInput(outputID.UTXOInput()) stateWithMetadata, err := l.memPool.StateMetadata(stateRef) if err != nil { - if ierrors.Is(iotago.ErrInputAlreadySpent, err) { + if ierrors.Is(err, iotago.ErrInputAlreadySpent) { l.utxoLedger.ReadLockLedger() defer l.utxoLedger.ReadUnlockLedger()