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 parameter naming to spec #352

Merged
merged 11 commits into from
Sep 21, 2023
2 changes: 1 addition & 1 deletion components/dashboard/jsonresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func NewSlotDetails(commitment *model.Commitment, diffs *utxoledger.SlotDiff) *S

return &SlotDetailsResponse{
Index: uint64(commitment.Index()),
PrevID: commitment.PrevID().ToHex(),
PrevID: commitment.PreviousCommitmentID().ToHex(),
RootsID: commitment.RootsID().ToHex(),
CumulativeWeight: commitment.CumulativeWeight(),
CreatedOutputs: createdOutputs,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20230829161228-3f4eb50a4d14
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3
github.com/labstack/echo/v4 v4.11.1
github.com/labstack/gommon v0.4.0
github.com/libp2p/go-libp2p v0.30.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b h1:EPB/+i
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20230829160617-69b96c7c9f9b/go.mod h1:B7gyJP6GshCSlEmY3CxEk5TZdsMs3UNz5U92hkFDdMs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo=
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3 h1:sGYy/hf5yz2/goNpZ02h+K46K+agu7QAK112mK7oZmo=
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo=
github.com/ipfs/boxo v0.10.0 h1:tdDAxq8jrsbRkYoF+5Rcqyeb91hgWe2hp7iLu7ORZLY=
github.com/ipfs/boxo v0.10.0/go.mod h1:Fg+BnfxZ0RPzR0nOodzdIq3A7KgoWAOWsEIImrIQdBM=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Commitment struct {

func NewEmptyCommitment(api iotago.API) *Commitment {
emptyCommitment := iotago.NewEmptyCommitment(api.ProtocolParameters().Version())
emptyCommitment.RMC = api.ProtocolParameters().CongestionControlParameters().RMCMin
emptyCommitment.ReferenceManaCost = api.ProtocolParameters().CongestionControlParameters().RMCMin

return lo.PanicOnErr(CommitmentFromCommitment(emptyCommitment, api))
}
Expand Down Expand Up @@ -83,8 +83,8 @@ func (c *Commitment) Index() iotago.SlotIndex {
return c.Commitment().Index
}

func (c *Commitment) PrevID() iotago.CommitmentID {
return c.Commitment().PrevID
jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
func (c *Commitment) PreviousCommitmentID() iotago.CommitmentID {
return c.Commitment().PreviousCommitmentID
}

func (c *Commitment) RootsID() iotago.Identifier {
Expand Down
14 changes: 7 additions & 7 deletions pkg/protocol/chainmanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (m *Manager) Commitments(id iotago.CommitmentID, amount int) (commitments [

commitments[i] = currentCommitment

id = currentCommitment.Commitment().PrevID()
id = currentCommitment.Commitment().PreviousCommitmentID()
}

return
Expand Down Expand Up @@ -237,8 +237,8 @@ func (m *Manager) SwitchMainChain(head iotago.CommitmentID) error {
func (m *Manager) processCommitment(commitment *model.Commitment) (wasForked bool, isSolid bool, chainCommitment *ChainCommitment) {
// Lock access to the parent commitment. We need to lock this first as we are trying to update children later within this function.
// Failure to do so, leads to a deadlock, where a child is locked and tries to lock its parent, which is locked by the parent which tries to lock the child.
m.commitmentEntityMutex.Lock(commitment.PrevID())
defer m.commitmentEntityMutex.Unlock(commitment.PrevID())
m.commitmentEntityMutex.Lock(commitment.PreviousCommitmentID())
defer m.commitmentEntityMutex.Unlock(commitment.PreviousCommitmentID())

// Lock access to the chainCommitment so no children are added while we are propagating solidity
m.commitmentEntityMutex.Lock(commitment.ID())
Expand Down Expand Up @@ -356,7 +356,7 @@ func (m *Manager) forkingPointAgainstMainChain(commitment *ChainCommitment) (*Ch
for chain := commitment.Chain(); chain != m.rootCommitment.Chain(); chain = commitment.Chain() {
forkingCommitment = chain.ForkingPoint

if commitment, _ = m.Commitment(forkingCommitment.Commitment().PrevID()); commitment == nil {
if commitment, _ = m.Commitment(forkingCommitment.Commitment().PreviousCommitmentID()); commitment == nil {
return nil, ierrors.Wrapf(ErrCommitmentUnknown, "unknown parent of solid commitment %s", forkingCommitment.Commitment().ID())
}
}
Expand All @@ -365,7 +365,7 @@ func (m *Manager) forkingPointAgainstMainChain(commitment *ChainCommitment) (*Ch
}

func (m *Manager) registerCommitment(commitment *model.Commitment) (isNew bool, isSolid bool, wasForked bool, chainCommitment *ChainCommitment) {
parentCommitment, commitmentCreated := m.getOrCreateCommitment(commitment.PrevID())
parentCommitment, commitmentCreated := m.getOrCreateCommitment(commitment.PreviousCommitmentID())
if commitmentCreated {
m.commitmentRequester.StartTicker(parentCommitment.ID())
}
Expand Down Expand Up @@ -398,7 +398,7 @@ func (m *Manager) switchMainChainToCommitment(commitment *ChainCommitment) error
return nil
}

parentCommitment, _ := m.Commitment(forkingPoint.Commitment().PrevID())
parentCommitment, _ := m.Commitment(forkingPoint.Commitment().PreviousCommitmentID())
if parentCommitment == nil {
return ierrors.Wrapf(ErrCommitmentUnknown, "unknown parent of solid commitment %s", forkingPoint.ID())
}
Expand All @@ -408,7 +408,7 @@ func (m *Manager) switchMainChainToCommitment(commitment *ChainCommitment) error

// For each forking point coming out of the main chain we need to reorg the children
for fp := commitment.Chain().ForkingPoint; ; {
fpParent, _ := m.Commitment(fp.Commitment().PrevID())
fpParent, _ := m.Commitment(fp.Commitment().PreviousCommitmentID())

mainChild := fpParent.mainChild()
newChildChain := NewChain(mainChild)
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/chainmanager/testframework.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (t *TestFramework) SlotCommitmentRoot(alias string) iotago.Identifier {
}

func (t *TestFramework) PrevSlotCommitment(alias string) iotago.CommitmentID {
return t.commitment(alias).PrevID()
return t.commitment(alias).PreviousCommitmentID()
}

func (t *TestFramework) AssertChainIsAlias(chain *Chain, alias string) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/protocol/engine/congestioncontrol/rmc/rmc.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (m *Manager) CommitSlot(index iotago.SlotIndex) (iotago.Mana, error) {
if err != nil {
return 0, ierrors.Wrapf(err, "failed to load commitment for slot %d", index-1)
}
lastRMC := latestCommitment.Commitment().RMC
lastRMC := latestCommitment.Commitment().ReferenceManaCost
// load the slotWork for the current slot
currentSlotWork, exists := m.slotWork.Get(index)
if !exists {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (m *Manager) RMC(slot iotago.SlotIndex) (iotago.Mana, error) {
if err != nil {
return 0, ierrors.Wrapf(err, "failed to get RMC for slot %d", slot)
}
rmc = latestCommitment.Commitment().RMC
rmc = latestCommitment.Commitment().ReferenceManaCost
}

return rmc, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/permanent/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (s *Settings) Export(writer io.WriteSeeker, targetCommitment *iotago.Commit
var err error
if targetCommitment != nil {
// We always know the version of the target commitment, so there can be no error.
commitmentBytes, err = lo.PanicOnErr(s.apiProvider.APIForVersion(targetCommitment.Version)).Encode(targetCommitment)
commitmentBytes, err = lo.PanicOnErr(s.apiProvider.APIForVersion(targetCommitment.ProtocolVersion)).Encode(targetCommitment)
if err != nil {
return ierrors.Wrap(err, "failed to encode target commitment")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func Test_TransitionAccount(t *testing.T) {
var slotIndexBlock1 iotago.SlotIndex = 1
activeNodes := []*mock.Node{node1}
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin

block1 := ts.IssueBlockAtSlotWithOptions("block1", slotIndexBlock1, genesisCommitment, node1, tx1)

Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/confirmation_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestConfirmationFlags(t *testing.T) {

// Verify that nodes have the expected states.
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down
8 changes: 4 additions & 4 deletions pkg/tests/protocol_engine_rollback_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestProtocol_EngineRollbackFinalization(t *testing.T) {

{
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestProtocol_EngineRollbackNoFinalization(t *testing.T) {

{
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down Expand Up @@ -484,7 +484,7 @@ func TestProtocol_EngineRollbackNoFinalizationLastSlot(t *testing.T) {

{
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down Expand Up @@ -675,7 +675,7 @@ func TestProtocol_EngineRollbackNoFinalizationBeforePointOfNoReturn(t *testing.T

{
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/protocol_engine_switching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestProtocol_EngineSwitching(t *testing.T) {

{
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/protocol_startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_StartNodeFromSnapshotAndDisk(t *testing.T) {

// Verify that nodes have the expected states.
genesisCommitment := iotago.NewEmptyCommitment(ts.API.ProtocolParameters().Version())
genesisCommitment.RMC = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
genesisCommitment.ReferenceManaCost = ts.API.ProtocolParameters().CongestionControlParameters().RMCMin
ts.AssertNodeState(ts.Nodes(),
testsuite.WithSnapshotImported(true),
testsuite.WithProtocolParameters(ts.API.ProtocolParameters()),
Expand Down
2 changes: 1 addition & 1 deletion tools/evil-spammer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/iotaledger/hive.go/runtime v0.0.0-20230906114834-b50190b9f9c2
github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000
github.com/iotaledger/iota-core/tools/genesis-snapshot v0.0.0-00010101000000-000000000000
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3
github.com/mr-tron/base58 v1.2.0
go.uber.org/atomic v1.11.0
)
Expand Down
2 changes: 2 additions & 0 deletions tools/evil-spammer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2 h1:ex
github.com/iotaledger/hive.go/stringify v0.0.0-20230906114834-b50190b9f9c2/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d h1:p9IchKq6kft758XDlnN/tAEXJMXGlmQPmbdxolba1gs=
github.com/iotaledger/iota.go/v4 v4.0.0-20230913143616-917572c7752d/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo=
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3 h1:sGYy/hf5yz2/goNpZ02h+K46K+agu7QAK112mK7oZmo=
github.com/iotaledger/iota.go/v4 v4.0.0-20230920040621-23911fecbdd3/go.mod h1:DWCa+mXRTGWBV0EHVuvToUxAEcICe2Pab9hBlxBamKo=
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/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
Expand Down
Loading