Skip to content

Commit

Permalink
Merge pull request #731 from iotaledger/block-failure-reason-improvem…
Browse files Browse the repository at this point in the history
…ents

Block failure reason improvements
  • Loading branch information
muXxer authored Feb 13, 2024
2 parents bdb2166 + 51f01dc commit 9857cad
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240212172835-f61c6d89d84d
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9
github.com/labstack/echo/v4 v4.11.4
github.com/labstack/gommon v0.4.2
github.com/libp2p/go-libp2p v0.32.2
Expand Down Expand Up @@ -150,7 +150,6 @@ require (
github.com/quic-go/quic-go v0.41.0 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/samber/lo v1.39.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.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 h1:Z7twy8
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506/go.mod h1:x8dn1yT4TtyucfQz1Qb4LrqjdxmOMy7oiRiVedLD2/s=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6 h1:BjXmT1Kt4+KM0pN2ctstZRsJ5syfmE/3O/AoZZbghH8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9 h1:a1Q/G8kyLdF1LL6odHTKA5y9STXp5jDIlXM5wQcphEE=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
github.com/ipfs/boxo v0.17.0 h1:fVXAb12dNbraCX1Cdid5BB6Kl62gVLNVA+e0EYMqAU0=
github.com/ipfs/boxo v0.17.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (c *PostSolidBlockFilter) ProcessSolidBlock(block *blocks.Block) {
if accountData.Credits.Value < 0 {
c.events.BlockFiltered.Trigger(&postsolidfilter.BlockFilteredEvent{
Block: block,
Reason: ierrors.Wrapf(iotago.ErrNegativeBIC, "block issuer account %s is locked due to negative BIC", block.ProtocolBlock().Header.IssuerID),
Reason: ierrors.Wrapf(iotago.ErrAccountLocked, "block issuer account %s", block.ProtocolBlock().Header.IssuerID),
})

return
Expand Down
2 changes: 1 addition & 1 deletion pkg/retainer/retainer/retainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func NewProvider() module.Provider[*engine.Engine, retainer.Retainer] {
})

transactionMetadata.OnRejected(func() {
r.RetainTransactionFailure(attachment, iotago.ErrTxConflicting)
r.RetainTransactionFailure(attachment, iotago.ErrTxConflictRejected)
})

transactionMetadata.OnAccepted(func() {
Expand Down
15 changes: 11 additions & 4 deletions pkg/tests/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
node1 := ts.AddValidatorNode("node1")
node2 := ts.AddNode("node2")

wallet1BIC := iotago.BlockIssuanceCredits(100_000)
wallet1BIC := iotago.BlockIssuanceCredits(100_000_000)
wallet2BIC := iotago.BlockIssuanceCredits(0)

wallet1 := ts.AddGenesisWallet("wallet 1", node2, testsuite.WithWalletBlockIssuanceCredits(wallet1BIC))
Expand Down Expand Up @@ -505,6 +505,9 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
// MODIFY EXISTING GENESIS ACCOUNT
var block1Slot iotago.SlotIndex = 1
var latestParents []iotago.BlockID
// The cost of the block that will make the account go negative.
// We store it so we can allot that amount later to unlock it.
block12ManaCost := iotago.Mana(0)
// Issue one block from each of the two block-issuers - one will go negative and the other has enough BICs.
{
block1Commitment := iotago.NewEmptyCommitment(ts.API)
Expand All @@ -513,6 +516,10 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
block11 := ts.IssueBasicBlockWithOptions("block1.1", wallet1, &iotago.TaggedData{}, mock.WithSlotCommitment(block1Commitment))
block12 := ts.IssueBasicBlockWithOptions("block1.2", wallet2, &iotago.TaggedData{}, mock.WithStrongParents(block11.ID()), mock.WithSlotCommitment(block1Commitment))

var err error
block12ManaCost, err = block12.ProtocolBlock().ManaCost(block1Commitment.ReferenceManaCost)
require.NoError(t, err)

// Commit BIC burns and check account states.
ts.CommitUntilSlot(ts.BlockID("block1.2").Slot(), block12.ID())

Expand Down Expand Up @@ -549,7 +556,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {

block22 := ts.IssueBasicBlockWithOptions("block2.2", wallet2, &iotago.TaggedData{}, mock.WithStrongParents(ts.BlockID("block2.1")), mock.WithSlotCommitment(block2Commitment))

ts.AssertBlockFiltered([]*blocks.Block{block22}, iotago.ErrNegativeBIC, wallet2.Node)
ts.AssertBlockFiltered([]*blocks.Block{block22}, iotago.ErrAccountLocked, wallet2.Node)

latestParents = ts.CommitUntilSlot(ts.BlockID("block2.1").Slot(), block21.ID())

Expand Down Expand Up @@ -579,7 +586,7 @@ func Test_NegativeBIC_BlockIssuerLocked(t *testing.T) {
// Allot some mana to the locked account to unlock it.
// The locked wallet 2 is preparing and signs the transaction, but it's issued by wallet 1 whose account is not locked.
{
allottedBIC := iotago.BlockIssuanceCredits(10_000)
allottedBIC := iotago.BlockIssuanceCredits(block12ManaCost)
tx1 := wallet2.AllotManaFromInputs("TX1",
iotago.Allotments{&iotago.Allotment{
AccountID: wallet2.BlockIssuer.AccountID,
Expand Down Expand Up @@ -761,7 +768,7 @@ func Test_NegativeBIC_AccountOutput(t *testing.T) {
// Allot some mana to the locked account to unlock it.
// The locked wallet 1 is preparing and signs the transaction, but it's issued by wallet 2 whose account is not locked.
{
allottedBIC := iotago.BlockIssuanceCredits(10001)
allottedBIC := iotago.BlockIssuanceCredits(100_000_000)
tx2 := wallet1.AllotManaFromInputs("TX2",
iotago.Allotments{&iotago.Allotment{
AccountID: wallet1.BlockIssuer.AccountID,
Expand Down
3 changes: 1 addition & 2 deletions tools/gendoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ require (
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240212172835-f61c6d89d84d // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 // indirect
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6 // indirect
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9 // indirect
github.com/ipfs/boxo v0.17.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
Expand Down Expand Up @@ -142,7 +142,6 @@ require (
github.com/quic-go/quic-go v0.41.0 // indirect
github.com/quic-go/webtransport-go v0.6.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/samber/lo v1.39.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.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tools/gendoc/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506 h1:Z7twy8
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240125161426-1846f6320506/go.mod h1:x8dn1yT4TtyucfQz1Qb4LrqjdxmOMy7oiRiVedLD2/s=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6 h1:BjXmT1Kt4+KM0pN2ctstZRsJ5syfmE/3O/AoZZbghH8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9 h1:a1Q/G8kyLdF1LL6odHTKA5y9STXp5jDIlXM5wQcphEE=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
github.com/ipfs/boxo v0.17.0 h1:fVXAb12dNbraCX1Cdid5BB6Kl62gVLNVA+e0EYMqAU0=
github.com/ipfs/boxo v0.17.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80=
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
Expand Down
3 changes: 1 addition & 2 deletions tools/genesis-snapshot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/iotaledger/hive.go/lo v0.0.0-20240126143305-9caf79103e85
github.com/iotaledger/hive.go/runtime v0.0.0-20240126143305-9caf79103e85
github.com/iotaledger/iota-core v0.0.0-00010101000000-000000000000
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9
github.com/mr-tron/base58 v1.2.0
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.18.0
Expand Down Expand Up @@ -55,7 +55,6 @@ require (
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pokt-network/smt v0.9.2 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tools/genesis-snapshot/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85 h1:wK
github.com/iotaledger/hive.go/stringify v0.0.0-20240126143305-9caf79103e85/go.mod h1:FTo/UWzNYgnQ082GI9QVM9HFDERqf9rw9RivNpqrnTs=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00 h1:j5udgLtSN6wQgFI9vnhkdJsqsVdJmwtoc0yOmT/Ila4=
github.com/iotaledger/iota-crypto-demo v0.0.0-20231208171603-786bb32fdb00/go.mod h1:gt+URx7DZu414nZME7jtGgxR4DVTSnNa1jF2trTUTZ0=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6 h1:BjXmT1Kt4+KM0pN2ctstZRsJ5syfmE/3O/AoZZbghH8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240205135859-2e6b70b484d6/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9 h1:a1Q/G8kyLdF1LL6odHTKA5y9STXp5jDIlXM5wQcphEE=
github.com/iotaledger/iota.go/v4 v4.0.0-20240213081357-427dfc95a1b9/go.mod h1:f7N7GyRbW4B0UWMvCeiXOrYiP9T2HVaQnZqP2zaZSo8=
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/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
Expand Down

0 comments on commit 9857cad

Please sign in to comment.