Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update inx-app to aa12c9f5bd66 #33

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions components/validator/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,14 @@ func committeeMemberAction(ctx context.Context) {
func issueCandidateBlock(ctx context.Context, blockIssuingTime time.Time, currentAPI iotago.API) error {
blockSlot := currentAPI.TimeProvider().SlotFromTime(blockIssuingTime)

strongParents, weakParents, shallowLikeParents, err := requestTips(ctx, iotago.BasicBlockMaxParents)
issuanceBlockHeaderResponse, err := blockIssuance(ctx, iotago.BasicBlockMaxParents)
if err != nil {
return ierrors.Wrapf(err, "failed to get tips")
return ierrors.Wrapf(err, "failed to get blockIssuance")
}

latestParentBlockIssuingTime := issuanceBlockHeaderResponse.LatestParentBlockIssuingTime.Add(time.Nanosecond)
if blockIssuingTime.Before(latestParentBlockIssuingTime) {
blockIssuingTime = latestParentBlockIssuingTime
}

addressableCommitment, err := getAddressableCommitment(ctx, blockSlot)
Expand All @@ -138,9 +143,9 @@ func issueCandidateBlock(ctx context.Context, blockIssuingTime time.Time, curren
IssuingTime(blockIssuingTime).
SlotCommitmentID(addressableCommitment.MustID()).
LatestFinalizedSlot(deps.NodeBridge.LatestFinalizedCommitment().Commitment.Slot).
alexsporn marked this conversation as resolved.
Show resolved Hide resolved
StrongParents(strongParents).
WeakParents(weakParents).
ShallowLikeParents(shallowLikeParents).
StrongParents(issuanceBlockHeaderResponse.StrongParents).
WeakParents(issuanceBlockHeaderResponse.WeakParents).
ShallowLikeParents(issuanceBlockHeaderResponse.ShallowLikeParents).
Payload(&iotago.CandidacyAnnouncement{}).
CalculateAndSetMaxBurnedMana(addressableCommitment.ReferenceManaCost).
Sign(validatorAccount.ID(), validatorAccount.PrivateKey()).
Expand All @@ -165,9 +170,14 @@ func issueValidationBlock(ctx context.Context, blockIssuingTime time.Time, curre
return ierrors.Wrapf(err, "failed to get protocol parameters hash")
}

strongParents, weakParents, shallowLikeParents, err := requestTips(ctx, iotago.ValidationBlockMaxParents)
issuanceBlockHeaderResponse, err := blockIssuance(ctx, iotago.ValidationBlockMaxParents)
if err != nil {
return ierrors.Wrapf(err, "failed to get tips")
return ierrors.Wrapf(err, "failed to get blockIssuance")
}

latestParentBlockIssuingTime := issuanceBlockHeaderResponse.LatestParentBlockIssuingTime.Add(time.Nanosecond)
if blockIssuingTime.Before(latestParentBlockIssuingTime) {
blockIssuingTime = latestParentBlockIssuingTime
}

addressableCommitment, err := getAddressableCommitment(ctx, currentAPI.TimeProvider().SlotFromTime(blockIssuingTime))
Expand All @@ -184,7 +194,9 @@ func issueValidationBlock(ctx context.Context, blockIssuingTime time.Time, curre
}

addressableCommitment = commitment
strongParents = []iotago.BlockID{parentID}
issuanceBlockHeaderResponse.StrongParents = []iotago.BlockID{parentID}
issuanceBlockHeaderResponse.WeakParents = []iotago.BlockID{}
issuanceBlockHeaderResponse.ShallowLikeParents = []iotago.BlockID{}
} else if err != nil {
return ierrors.Wrapf(err, "error getting commitment")
}
Expand All @@ -196,9 +208,9 @@ func issueValidationBlock(ctx context.Context, blockIssuingTime time.Time, curre
SlotCommitmentID(addressableCommitment.MustID()).
HighestSupportedVersion(deps.NodeBridge.APIProvider().LatestAPI().Version()).
LatestFinalizedSlot(deps.NodeBridge.LatestFinalizedCommitment().Commitment.Slot).
StrongParents(strongParents).
WeakParents(weakParents).
ShallowLikeParents(shallowLikeParents).
StrongParents(issuanceBlockHeaderResponse.StrongParents).
WeakParents(issuanceBlockHeaderResponse.WeakParents).
ShallowLikeParents(issuanceBlockHeaderResponse.ShallowLikeParents).
Sign(validatorAccount.ID(), validatorAccount.PrivateKey()).
Build()
if err != nil {
Expand Down
11 changes: 6 additions & 5 deletions components/validator/nodebridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (

"github.com/iotaledger/inx-app/pkg/nodebridge"
iotago "github.com/iotaledger/iota.go/v4"
"github.com/iotaledger/iota.go/v4/api"
)

const (
TimeoutINXReadIsCandidate = 1 * time.Second
TimeoutINXReadIsCommitteeMember = 1 * time.Second
TimeoutINXReadIsValidatorAccount = 1 * time.Second
TimeoutINXRequestTips = 2 * time.Second
TimeoutINXBlockIssuance = 2 * time.Second
TimeoutINXSubmitBlock = 2 * time.Second
TimeoutINXActiveRootBlocks = 2 * time.Second
TimeoutINXForceCommitUntil = 5 * time.Second
Expand Down Expand Up @@ -43,12 +44,12 @@ func readIsValidatorAccount(ctx context.Context, accountID iotago.AccountID, slo
return deps.NodeBridge.ReadIsValidatorAccount(ctx, accountID, slot)
}

// requestTips requests tips from the node.
func requestTips(ctx context.Context, count uint32) (iotago.BlockIDs, iotago.BlockIDs, iotago.BlockIDs, error) {
ctx, cancel := context.WithTimeout(ctx, TimeoutINXRequestTips)
// blockIssuance requests the necessary data to issue a block.
func blockIssuance(ctx context.Context, maxParentCount uint32) (*api.IssuanceBlockHeaderResponse, error) {
ctx, cancel := context.WithTimeout(ctx, TimeoutINXBlockIssuance)
defer cancel()

return deps.NodeBridge.RequestTips(ctx, count)
return deps.NodeBridge.BlockIssuance(ctx, maxParentCount)
}

// submitBlock submits a block to the node.
Expand Down
53 changes: 26 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,53 @@ module github.com/iotaledger/inx-validator
go 1.22

require (
github.com/iotaledger/hive.go/app v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/crypto v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/ierrors v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/runtime v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240320125204-646f949dc816
github.com/iotaledger/iota.go/v4 v4.0.0-20240320124121-0b5258b05dbc
github.com/iotaledger/hive.go/app v0.0.0-20240419094509-31dbb7270ad9
github.com/iotaledger/hive.go/crypto v0.0.0-20240419094509-31dbb7270ad9
github.com/iotaledger/hive.go/ierrors v0.0.0-20240419094509-31dbb7270ad9
github.com/iotaledger/hive.go/runtime v0.0.0-20240419094509-31dbb7270ad9
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240419103152-aa12c9f5bd66
github.com/iotaledger/iota.go/v4 v4.0.0-20240419095144-054bd7d2ba61
go.uber.org/dig v1.17.1

)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect
github.com/ethereum/go-ethereum v1.13.14 // indirect
github.com/ethereum/go-ethereum v1.13.15 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/fgprof v0.9.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20240319011627-a57c5dfe54fd // indirect
github.com/google/pprof v0.0.0-20240416155748-26353dc0451f // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/ds v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/lo v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/log v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240320124425-aef029f6d349 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/ds v0.0.0-20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/lo v0.0.0-20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/log v0.0.0-20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240419094509-31dbb7270ad9 // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240419095729-912f1c2df45d // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pelletier/go-toml/v2 v2.2.1 // indirect
github.com/petermattis/goid v0.0.0-20240327183114-c42a807a84ba // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.50.0 // indirect
Expand All @@ -59,13 +58,13 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading
Loading