Skip to content

Commit

Permalink
Merge pull request #574 from iotaledger/chore/update-iotago
Browse files Browse the repository at this point in the history
Adapt to iota.go API changes
  • Loading branch information
muXxer authored Nov 28, 2023
2 parents 1f95534 + 2406726 commit 85c495a
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 196 deletions.
6 changes: 3 additions & 3 deletions components/restapi/core/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func validatorByAccountAddress(c echo.Context) (*api.ValidatorResponse, error) {
AddressBech32: accountID.ToAddress().Bech32(deps.Protocol.CommittedAPI().ProtocolParameters().Bech32HRP()),
PoolStake: accountData.ValidatorStake + accountData.DelegationStake,
ValidatorStake: accountData.ValidatorStake,
StakingEpochEnd: accountData.StakeEndEpoch,
StakingEndEpoch: accountData.StakeEndEpoch,
FixedCost: accountData.FixedCost,
Active: active,
LatestSupportedProtocolVersion: accountData.LatestSupportedProtocolVersionAndHash.Version,
Expand Down Expand Up @@ -232,8 +232,8 @@ func rewardsByOutputID(c echo.Context) (*api.ManaRewardsResponse, error) {
}

return &api.ManaRewardsResponse{
EpochStart: actualStart,
EpochEnd: actualEnd,
StartEpoch: actualStart,
EndEpoch: actualEnd,
Rewards: reward,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion components/restapi/core/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func blockIssuance() (*api.IssuanceBlockHeaderResponse, error) {
WeakParents: references[iotago.WeakParentType],
ShallowLikeParents: references[iotago.ShallowLikeParentType],
LatestFinalizedSlot: deps.Protocol.MainEngineInstance().SyncManager.LatestFinalizedSlot(),
Commitment: deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Commitment(),
LatestCommitment: deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment().Commitment(),
}

return resp, nil
Expand Down
71 changes: 34 additions & 37 deletions components/restapi/core/utxo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/inx-app/pkg/httpserver"
"github.com/iotaledger/iota-core/pkg/protocol/engine/utxoledger"
iotago "github.com/iotaledger/iota.go/v4"
"github.com/iotaledger/iota.go/v4/api"
)

Expand Down Expand Up @@ -83,57 +84,53 @@ func outputWithMetadataByID(c echo.Context) (*api.OutputWithMetadataResponse, er
func newOutputMetadataResponse(output *utxoledger.Output) (*api.OutputMetadata, error) {
latestCommitment := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment()

resp := &api.OutputMetadata{
BlockID: output.BlockID(),
TransactionID: output.OutputID().TransactionID(),
OutputIndex: output.OutputID().Index(),
IsSpent: false,
LatestCommitmentID: latestCommitment.ID(),
}
includedSlot := output.SlotBooked()
includedCommitmentID := iotago.EmptyCommitmentID

includedSlotIndex := output.SlotBooked()
genesisSlot := deps.Protocol.MainEngineInstance().CommittedAPI().ProtocolParameters().GenesisSlot()
if includedSlotIndex <= latestCommitment.Slot() && includedSlotIndex >= genesisSlot {
includedCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(includedSlotIndex)
if includedSlot <= latestCommitment.Slot() &&
includedSlot >= deps.Protocol.MainEngineInstance().CommittedAPI().ProtocolParameters().GenesisSlot() {
includedCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(includedSlot)
if err != nil {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load commitment with index %d: %s", includedSlotIndex, err)
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load commitment with index %d: %s", includedSlot, err)
}
resp.IncludedCommitmentID = includedCommitment.ID()
includedCommitmentID = includedCommitment.ID()
}

return resp, nil
return &api.OutputMetadata{
OutputID: output.OutputID(),
BlockID: output.BlockID(),
Included: &api.OutputInclusionMetadata{
Slot: includedSlot,
TransactionID: output.OutputID().TransactionID(),
CommitmentID: includedCommitmentID,
},
LatestCommitmentID: latestCommitment.ID(),
}, nil
}

func newSpentMetadataResponse(spent *utxoledger.Spent) (*api.OutputMetadata, error) {
latestCommitment := deps.Protocol.MainEngineInstance().SyncManager.LatestCommitment()

resp := &api.OutputMetadata{
BlockID: spent.BlockID(),
TransactionID: spent.OutputID().TransactionID(),
OutputIndex: spent.OutputID().Index(),
IsSpent: true,
TransactionIDSpent: spent.TransactionIDSpent(),
LatestCommitmentID: latestCommitment.ID(),
newOutputMetadataResponse, err := newOutputMetadataResponse(spent.Output())
if err != nil {
return nil, err
}

includedSlotIndex := spent.Output().SlotBooked()
genesisSlot := deps.Protocol.MainEngineInstance().CommittedAPI().ProtocolParameters().GenesisSlot()
if includedSlotIndex <= latestCommitment.Slot() && includedSlotIndex >= genesisSlot {
includedCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(includedSlotIndex)
spentSlot := spent.SlotSpent()
spentCommitmentID := iotago.EmptyCommitmentID

if spentSlot <= newOutputMetadataResponse.LatestCommitmentID.Slot() &&
spentSlot >= deps.Protocol.MainEngineInstance().CommittedAPI().ProtocolParameters().GenesisSlot() {
spentCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(spentSlot)
if err != nil {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load commitment with index %d: %s", includedSlotIndex, err)
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load commitment with index %d: %s", spentSlot, err)
}
resp.IncludedCommitmentID = includedCommitment.ID()
spentCommitmentID = spentCommitment.ID()
}

spentSlotIndex := spent.SlotSpent()
if spentSlotIndex <= latestCommitment.Slot() && spentSlotIndex >= genesisSlot {
spentCommitment, err := deps.Protocol.MainEngineInstance().Storage.Commitments().Load(spentSlotIndex)
if err != nil {
return nil, ierrors.Wrapf(echo.ErrInternalServerError, "failed to load commitment with index %d: %s", spentSlotIndex, err)
}
resp.CommitmentIDSpent = spentCommitment.ID()
newOutputMetadataResponse.Spent = &api.OutputConsumptionMetadata{
Slot: spentSlot,
TransactionID: spent.TransactionIDSpent(),
CommitmentID: spentCommitmentID,
}

return resp, nil
return newOutputMetadataResponse, nil
}
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/iotaledger/hive.go/ads v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/app v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/constraints v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/constraints v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/crypto v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/crypto v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/ds v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/ierrors v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/ierrors v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/kvstore v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/lo v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/lo v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/logger v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/runtime v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/runtime v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20231127134220-90b88e35bdb2
github.com/iotaledger/hive.go/stringify v0.0.0-20231127134220-90b88e35bdb2
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231123103852-bb039cbab83b
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231123103318-f6ea945e2e98
github.com/iotaledger/iota.go/v4 v4.0.0-20231124103306-ad44904e2b86
github.com/iotaledger/hive.go/stringify v0.0.0-20231128121006-331a9e522dfe
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20231128163614-c82e1fa40733
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20231128162307-cc6b309e93ef
github.com/iotaledger/iota.go/v4 v4.0.0-20231128162016-23f1b4e12cec
github.com/labstack/echo/v4 v4.11.3
github.com/labstack/gommon v0.4.1
github.com/libp2p/go-libp2p v0.32.0
Expand All @@ -41,7 +41,7 @@ require (
github.com/zyedidia/generic v1.2.1
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.17.1
golang.org/x/crypto v0.15.0
golang.org/x/crypto v0.16.0
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
Expand Down Expand Up @@ -85,7 +85,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/holiman/uint256 v1.2.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/grocksdb v1.7.5-0.20230220105546-5162e18885c7 // indirect
Expand Down Expand Up @@ -171,14 +171,14 @@ require (
go.uber.org/zap v1.26.0 // indirect
golang.org/x/image v0.13.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.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/tools v0.14.0 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
Expand Down
Loading

0 comments on commit 85c495a

Please sign in to comment.