Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Conversation

@gyuho
Copy link
Contributor

@gyuho gyuho commented Nov 18, 2021

No description provided.

@gyuho gyuho changed the title [WIP] *: initial crypto util packages, transaction interface *: clean up crypto, transaction interface Nov 19, 2021
infoPrefix = 0x0
keyPrefix = 0x1
txPrefix = 0x2
delimiter = 0x7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a bug, we actually need to use a prohibited delimiter here (rn you could 0x7). Recording here to make sure I don't forget.

"github.com/ava-labs/quarkvm/vm/codec"
)

// 0x0/ (singleton prefix info)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably convert these to 3 prefix dbs instead of doing that initial prefix manually.

return err
}
return db.Put(PrefixTxKey(t.ID()), nil)
return db.Put(prefix.TxKey(t.ID()), nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

vm/vm.go Outdated
return nil, errNoPendingBlocks
}

// TODO: prune mempool?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove txs that are no longer valid. We probably want to do this async in the mempool because not everyone will end up trying to build a block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, was looking at simple-kvvm code, let me follow that pattern.

vm/block.go Outdated
return uint64(len(b.Bytes()))
}

func (b *block) Verify(c *Chain) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big other bug I had was not verifying this block against the parent state (rn it is just verified against the current state). If more than 1 block is processing, this will lead to issues.

We need to use the VersionDB to fix this (I can do it).

vm/chain.go Outdated
}

// TODO: wrap entire accept in atomic commit
if err := b.Accept(c.db); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We won't accept here (as the block we issue may not be accepted by the network). This should really only be called the consensus engine.

Instead, we'll verify it, mark as processing, then pass to the engine.

vm/block.go Outdated
return errors.New("no fee-paying transactions")
}
lastBlock := c.blocks[len(c.blocks)-1]
if b.Time < lastBlock.Time {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to make sure block time not > VM's current time by something reasonable (like 10s)

vm/chain.go Outdated
db database.Database

mempool transaction.Mempool
blocks []*block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should prune this blocks array to only include the window (we'll need to populate it on startup as well based on what last accepted block is)

@gyuho gyuho changed the title *: clean up crypto, transaction interface *: reorg packages, copying from simple-kvvm Nov 19, 2021
@gyuho gyuho force-pushed the tx branch 12 times, most recently from c18cdbd to 14b2529 Compare November 21, 2021 22:04
Signed-off-by: Gyuho Lee <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants