Skip to content

Commit

Permalink
Debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Mar 11, 2024
1 parent db3c503 commit 48f7996
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions block.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ func (b *Block) ManaCost(rmc Mana) (Mana, error) {

// syntacticallyValidate syntactically validates the Block.
func (b *Block) syntacticallyValidate() error {
fmt.Println(">>>>>printed from iota.go", b)
if b.Size() > MaxBlockSize {
return ierrors.Wrapf(ErrBlockMaxSizeExceeded, "max size of a block is %d but got %d bytes", MaxBlockSize, b.Size())
}
Expand Down Expand Up @@ -306,16 +307,19 @@ func (b *Block) syntacticallyValidate() error {
return ierrors.Wrapf(err, "failed to syntactically validate block")
}
blockSlot := blockID.Slot()
fmt.Println(">>>from iota.go", commitmentSlot, minCommittableAge, blockSlot, genesisSlot, maxCommittableAge)
fmt.Println(">>>from iota.go", commitmentSlot+maxCommittableAge)

// check that commitment is not too recent.
if commitmentSlot > genesisSlot && // Don't filter commitments to genesis based on being too recent.
blockSlot < commitmentSlot+minCommittableAge {
return ierrors.Wrapf(ErrCommitmentTooRecent, "block at slot %d committing to slot %d", blockSlot, b.Header.SlotCommitmentID.Slot())
return ierrors.Wrapf(ErrCommitmentTooRecent, "block at slot %d committing to slot %d", blockSlot, commitmentSlot)
}

// Check that commitment is not too old.
if blockSlot > commitmentSlot+maxCommittableAge {
return ierrors.Wrapf(ErrCommitmentTooOld, "block at slot %d committing to slot %d, max committable age %d", blockSlot, b.Header.SlotCommitmentID.Slot(), maxCommittableAge)
errStr := fmt.Sprintf("block at slot %d committing to slot %d, max committable age %d", blockSlot, commitmentSlot, maxCommittableAge)
return ierrors.Wrap(ErrCommitmentTooOld, errStr)
}

return b.Body.syntacticallyValidate(b)
Expand Down
4 changes: 2 additions & 2 deletions builder/block_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (b *BasicBlockBuilder) SlotCommitmentID(commitment iotago.CommitmentID) *Ba
return b
}

b.protocolBlock.Header.SlotCommitmentID = commitment
copy(b.protocolBlock.Header.SlotCommitmentID[:], commitment[:])

return b
}
Expand Down Expand Up @@ -283,7 +283,7 @@ func (v *ValidationBlockBuilder) SlotCommitmentID(commitmentID iotago.Commitment
return v
}

v.protocolBlock.Header.SlotCommitmentID = commitmentID
copy(v.protocolBlock.Header.SlotCommitmentID[:], commitmentID[:])

return v
}
Expand Down

0 comments on commit 48f7996

Please sign in to comment.