Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/reduce-conten…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
piotrm50 committed Dec 6, 2023
2 parents 2228ee2 + a377997 commit dc1abd0
Show file tree
Hide file tree
Showing 38 changed files with 294 additions and 328 deletions.
28 changes: 23 additions & 5 deletions components/restapi/core/blocks.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package core

import (
"time"

"github.com/labstack/echo/v4"

"github.com/iotaledger/hive.go/ierrors"
Expand Down Expand Up @@ -84,12 +86,28 @@ func blockIssuance() (*api.IssuanceBlockHeaderResponse, error) {
return nil, ierrors.Wrap(echo.ErrServiceUnavailable, "no strong parents available")
}

// get the latest parent block issuing time
var latestParentBlockIssuingTime time.Time
for _, parentType := range []iotago.ParentsType{iotago.StrongParentType, iotago.WeakParentType, iotago.ShallowLikeParentType} {
for _, blockID := range references[parentType] {
block, exists := deps.Protocol.Engines.Main.Get().Block(blockID)
if !exists {
return nil, ierrors.Wrapf(echo.ErrNotFound, "no block found for parent, block ID: %s", blockID.ToHex())
}

if latestParentBlockIssuingTime.Before(block.ProtocolBlock().Header.IssuingTime) {
latestParentBlockIssuingTime = block.ProtocolBlock().Header.IssuingTime
}
}
}

resp := &api.IssuanceBlockHeaderResponse{
StrongParents: references[iotago.StrongParentType],
WeakParents: references[iotago.WeakParentType],
ShallowLikeParents: references[iotago.ShallowLikeParentType],
LatestFinalizedSlot: deps.Protocol.Engines.Main.Get().SyncManager.LatestFinalizedSlot(),
LatestCommitment: deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment(),
StrongParents: references[iotago.StrongParentType],
WeakParents: references[iotago.WeakParentType],
ShallowLikeParents: references[iotago.ShallowLikeParentType],
LatestParentBlockIssuingTime: latestParentBlockIssuingTime,
LatestFinalizedSlot: deps.Protocol.Engines.Main.Get().SyncManager.LatestFinalizedSlot(),
LatestCommitment: deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Commitment(),
}

return resp, nil
Expand Down
30 changes: 30 additions & 0 deletions components/restapi/core/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,33 @@ func getUTXOChanges(commitmentID iotago.CommitmentID) (*api.UTXOChangesResponse,
ConsumedOutputs: consumedOutputs,
}, nil
}

func getUTXOChangesFull(commitmentID iotago.CommitmentID) (*api.UTXOChangesFullResponse, error) {
diffs, err := deps.Protocol.Engines.Main.Get().Ledger.SlotDiffs(commitmentID.Slot())
if err != nil {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to get slot diffs, commitmentID: %s, slot: %d, error: %w", commitmentID, commitmentID.Slot(), err)
}

createdOutputs := make([]*api.OutputWithID, len(diffs.Outputs))
consumedOutputs := make([]*api.OutputWithID, len(diffs.Spents))

for i, output := range diffs.Outputs {
createdOutputs[i] = &api.OutputWithID{
OutputID: output.OutputID(),
Output: output.Output(),
}
}

for i, output := range diffs.Spents {
consumedOutputs[i] = &api.OutputWithID{
OutputID: output.OutputID(),
Output: output.Output().Output(),
}
}

return &api.UTXOChangesFullResponse{
CommitmentID: commitmentID,
CreatedOutputs: createdOutputs,
ConsumedOutputs: consumedOutputs,
}, nil
}
39 changes: 39 additions & 0 deletions components/restapi/core/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,26 @@ func configure() error {
return responseByHeader(c, resp)
})

routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentByIDUTXOChangesFull), func(c echo.Context) error {
commitmentID, err := httpserver.ParseCommitmentIDParam(c, api.ParameterCommitmentID)
if err != nil {
return err
}

// load the commitment to check if it matches the given commitmentID
commitment, err := getCommitmentByID(commitmentID)
if err != nil {
return err
}

resp, err := getUTXOChangesFull(commitment.ID())
if err != nil {
return err
}

return responseByHeader(c, resp)
})

routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentBySlot), func(c echo.Context) error {
index, err := httpserver.ParseSlotParam(c, api.ParameterSlot)
if err != nil {
Expand Down Expand Up @@ -175,6 +195,25 @@ func configure() error {
return responseByHeader(c, resp)
})

routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointCommitmentBySlotUTXOChangesFull), func(c echo.Context) error {
slot, err := httpserver.ParseSlotParam(c, api.ParameterSlot)
if err != nil {
return err
}

commitment, err := getCommitmentBySlot(slot)
if err != nil {
return err
}

resp, err := getUTXOChangesFull(commitment.ID())
if err != nil {
return err
}

return responseByHeader(c, resp)
})

routeGroup.GET(api.EndpointWithEchoParameters(api.CoreEndpointOutput), func(c echo.Context) error {
resp, err := outputByID(c)
if err != nil {
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ require (
github.com/google/uuid v1.4.0
github.com/gorilla/websocket v1.5.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/ads v0.0.0-20231205131244-472357435a39
github.com/iotaledger/hive.go/app v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/constraints v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/crypto v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/ds v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/ierrors v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/kvstore v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/kvstore v0.0.0-20231205131244-472357435a39
github.com/iotaledger/hive.go/lo v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/log v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/log v0.0.0-20231206113509-4b4ff95ac61c
github.com/iotaledger/hive.go/logger v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/runtime v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231206114953-6a65a82e30ad
github.com/iotaledger/hive.go/stringify v0.0.0-20231206114953-6a65a82e30ad
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665
github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231206124511-b78dc962031f
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231206124145-f773dfe3927e
github.com/iotaledger/iota.go/v4 v4.0.0-20231206123921-2af411eef0b5
github.com/labstack/echo/v4 v4.11.3
github.com/labstack/gommon v0.4.1
github.com/libp2p/go-libp2p v0.32.0
Expand Down Expand Up @@ -155,7 +155,7 @@ require (
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
Expand All @@ -175,7 +175,7 @@ require (
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.4.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
Expand Down
32 changes: 16 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJ
github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 h1:dTrD7X2PTNgli6EbS4tV9qu3QAm/kBU3XaYZV2xdzys=
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7/go.mod h1:ZRdPu684P0fQ1z8sXz4dj9H5LWHhz4a9oCtvjunkSrw=
github.com/iotaledger/hive.go/ads v0.0.0-20231206114953-6a65a82e30ad h1:Sy6PPo5TWnWeZ3vdIf6NSvZ1RUf05IHY14oDvqD8rcY=
github.com/iotaledger/hive.go/ads v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:okMn9dNDf6jn46o72P3e55XCQObLNkzujM2abNXqW8E=
github.com/iotaledger/hive.go/ads v0.0.0-20231205131244-472357435a39 h1:jxoBAPgC4I73pAwvEWI2IUCxiI1xN68IaFZ5WC1D3ek=
github.com/iotaledger/hive.go/ads v0.0.0-20231205131244-472357435a39/go.mod h1:gbUvr01B5ha530GnNm8K2OsHXOd2BtzBYOMxyTX3iDg=
github.com/iotaledger/hive.go/app v0.0.0-20231206114953-6a65a82e30ad h1:v7dkbVLSsmzgOWT2vjvv1MdKQXvqFbvIkx8mvh6VK7g=
github.com/iotaledger/hive.go/app v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:hTHKGFbZnuiW8yEgDuuL7ZjQTCnl8bXyHLmj3LPa648=
github.com/iotaledger/hive.go/constraints v0.0.0-20231206114953-6a65a82e30ad h1:4XL7IIvdsWHxSKQfU+sgq3H9egN54053LF9TwMfDcTg=
Expand All @@ -289,12 +289,12 @@ github.com/iotaledger/hive.go/ds v0.0.0-20231206114953-6a65a82e30ad h1:adLrD6dOE
github.com/iotaledger/hive.go/ds v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:NmZRIoxtL6iQdVK6n5W+JOx58K/0Yn8k7WuSvpKPQ+M=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231206114953-6a65a82e30ad h1:WDl58zJKHfwbzHs+ZB8Jq3YNgVQE5Neu2NeaX3FZuyU=
github.com/iotaledger/hive.go/ierrors v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:HcE8B5lP96enc/OALTb2/rIIi+yOLouRoHOKRclKmC8=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231206114953-6a65a82e30ad h1:XD4VvKVwDfsXVUWCIEXMzW3zkNdYTBqUPu+3Z7CwfZY=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:8t45SAcTjQfF+zcFERtSRKy16u/gSquTfOtoSdCeyq4=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231205131244-472357435a39 h1:Gp2h+Els9cTVYYnYsHX3zLuixb0XggIj2okK570aKww=
github.com/iotaledger/hive.go/kvstore v0.0.0-20231205131244-472357435a39/go.mod h1:ytfKoHr/nF8u0y0G4mamfG0yjFtJiJVk0kgjnPOtsSY=
github.com/iotaledger/hive.go/lo v0.0.0-20231206114953-6a65a82e30ad h1:qpCsjw+InLL824QPu3lY/osck4DhucBKhCs5/E8OH+A=
github.com/iotaledger/hive.go/lo v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:ETXGXymFyNcUq2t4I9e7ZK18f9bxUWYat4pjZ9W0rWc=
github.com/iotaledger/hive.go/log v0.0.0-20231206114953-6a65a82e30ad h1:S46YvLM8TPjYTELNyeSeVIiqllR873lYxkEUvSqZtIc=
github.com/iotaledger/hive.go/log v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:Td3R6QmYw0svZI1GuZ/tN9s0VNaHassXSKLCc70aX9w=
github.com/iotaledger/hive.go/log v0.0.0-20231206113509-4b4ff95ac61c h1:Ksts6VjPj9y0o2Nis+2tHtDGWITNJ4yju87ZlHLPuOo=
github.com/iotaledger/hive.go/log v0.0.0-20231206113509-4b4ff95ac61c/go.mod h1:Td3R6QmYw0svZI1GuZ/tN9s0VNaHassXSKLCc70aX9w=
github.com/iotaledger/hive.go/logger v0.0.0-20231206114953-6a65a82e30ad h1:fazCxogqOLDEPNDPWYDLTDpYmwgTJgIaC2Z6VN52S4M=
github.com/iotaledger/hive.go/logger v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:hVaVODS+Uik0obf3SVEHFQNruUko/uqIgD/GKwhn49M=
github.com/iotaledger/hive.go/runtime v0.0.0-20231206114953-6a65a82e30ad h1:HpupWK8iqFt+Sdogkh2/N8ojalmevYy+FzhjOuy7Y7E=
Expand All @@ -303,12 +303,12 @@ github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231206114953-6a65a82
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231206114953-6a65a82e30ad/go.mod h1:FoH3T6yKlZJp8xm8K+zsQiibSynp32v21CpWx8xkek8=
github.com/iotaledger/hive.go/stringify v0.0.0-20231206114953-6a65a82e30ad h1:VC3OgdSbyngY7/gxVj66fKd/nGmN6P0/myr348nx7vA=
github.com/iotaledger/hive.go/stringify v0.0.0-20231206114953-6a65a82e30ad/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221 h1:+ozrau44uPy2kYv2fuj2Wks8+VkXR62WB9zONOJgzdE=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231201123347-1c44b3f24221/go.mod h1:6cLX3gnhP0WL+Q+mf3/rIqfACe5fWKVR8luPXWh2xiY=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665 h1:XdhojOpZ0t0pJFyNO0zlBogSAUrhEI67eCpTC9H6sGM=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231201114846-3bb5c3fd5665/go.mod h1:obK1N42oafGA7EH6zC4VX2fKh7jTa3WnIa9h1azfxq0=
github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d h1:MPklxa8jW4/EgDm/LEzf6orxjik7U+vMUW/ToGT1Zqg=
github.com/iotaledger/iota.go/v4 v4.0.0-20231204142547-416c9a87403d/go.mod h1:lCk9rhP3B5pX9BKhzR+Jobq4xPd+GHlqgF4Ga+eQfWA=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231206124511-b78dc962031f h1:V68Ijq1A64gB9r0Rhc4ybLGH66rXqZ2Ly0L4uuaLrMg=
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231206124511-b78dc962031f/go.mod h1:Dy3Gv4Dn1zufB177x6IXETP3zTeiWQ1+HMVQR0Bt/ew=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231206124145-f773dfe3927e h1:jbtiUlmTpTdGiRBW1pniPSqRcDMJaIW8fGS+uORryas=
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231206124145-f773dfe3927e/go.mod h1:zEb9onVHnDUStl5SsFBj7H0HBKfIN0c/pUND8Llfqp8=
github.com/iotaledger/iota.go/v4 v4.0.0-20231206123921-2af411eef0b5 h1:0KgQFpVRnKd6CdCwXo3Kg/SL27xkeKh2SMoU5G1TkZk=
github.com/iotaledger/iota.go/v4 v4.0.0-20231206123921-2af411eef0b5/go.mod h1:tiswk1O1wSAi9GE6tD1j43+bLmWU9Je07aZLaJ0+Ha0=
github.com/ipfs/boxo v0.13.1 h1:nQ5oQzcMZR3oL41REJDcTbrvDvuZh3J9ckc9+ILeRQI=
github.com/ipfs/boxo v0.13.1/go.mod h1:btrtHy0lmO1ODMECbbEY1pxNtrLilvKSYLoGQt1yYCk=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down Expand Up @@ -623,8 +623,8 @@ github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:Udh
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down Expand Up @@ -831,8 +831,8 @@ golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.4.0 h1:Z81tqI5ddIoXDPvVQ7/7CC9TnLM7ubaFG2qXYd5BbYY=
golang.org/x/time v0.4.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
5 changes: 3 additions & 2 deletions pkg/protocol/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func newChains(protocol *Protocol) *Chains {

shutdown := lo.Batch(
c.initLogger(protocol.NewChildLogger("Chains")),
c.initChainSwitching(protocol.Options.ChainSwitchingThreshold),
c.initChainSwitching(),

protocol.Constructed.WithNonEmptyValue(func(_ bool) (shutdown func()) {
return c.deriveLatestSeenSlot(protocol)
Expand Down Expand Up @@ -92,7 +92,7 @@ func (c *Chains) initLogger(logger log.Logger, shutdownLogger func()) (shutdown
}

// initChainSwitching initializes the chain switching logic.
func (c *Chains) initChainSwitching(chainSwitchingThreshold iotago.SlotIndex) (shutdown func()) {
func (c *Chains) initChainSwitching() (shutdown func()) {
mainChain := c.newChain()
mainChain.StartEngine.Set(true)

Expand All @@ -102,6 +102,7 @@ func (c *Chains) initChainSwitching(chainSwitchingThreshold iotago.SlotIndex) (s
forkingPointBelowChainSwitchingThreshold := func(chain *Chain) func(_ *Commitment, latestCommitment *Commitment) bool {
return func(_ *Commitment, latestCommitment *Commitment) bool {
forkingPoint := chain.ForkingPoint.Get()
chainSwitchingThreshold := iotago.SlotIndex(c.protocol.APIForSlot(latestCommitment.Slot()).ProtocolParameters().ChainSwitchingThreshold())

return forkingPoint != nil && latestCommitment != nil && (latestCommitment.ID().Slot()-forkingPoint.ID().Slot()) > chainSwitchingThreshold
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/protocol/engine/accounts/accountsledger/testsuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type TestSuite struct {
}

func NewTestSuite(test *testing.T) *TestSuite {
testAPI := tpkg.TestAPI
testAPI := tpkg.ZeroCostTestAPI

t := &TestSuite{
T: test,
Expand All @@ -65,7 +65,7 @@ func (t *TestSuite) initAccountLedger() *accountsledger.Manager {
prunableStores[slot] = mapdb.NewMapDB()
}

p := slotstore.NewAccountDiffs(slot, prunableStores[slot], tpkg.TestAPI)
p := slotstore.NewAccountDiffs(slot, prunableStores[slot], tpkg.ZeroCostTestAPI)

return p, nil
}
Expand Down Expand Up @@ -187,8 +187,8 @@ func (t *TestSuite) ApplySlotActions(slot iotago.SlotIndex, rmc iotago.Mana, act
}

func (t *TestSuite) createBlockWithRMC(accountID iotago.AccountID, slot iotago.SlotIndex, rmc iotago.Mana) *blocks.Block {
innerBlock := tpkg.RandBasicBlockWithIssuerAndRMC(tpkg.TestAPI, accountID, rmc)
innerBlock.Header.IssuingTime = tpkg.TestAPI.TimeProvider().SlotStartTime(slot)
innerBlock := tpkg.RandBasicBlockWithIssuerAndRMC(tpkg.ZeroCostTestAPI, accountID, rmc)
innerBlock.Header.IssuingTime = tpkg.ZeroCostTestAPI.TimeProvider().SlotStartTime(slot)
modelBlock, err := model.BlockFromBlock(innerBlock)

require.NoError(t.T, err)
Expand Down
Loading

0 comments on commit dc1abd0

Please sign in to comment.