-
Notifications
You must be signed in to change notification settings - Fork 28
*: reorg packages, copying from simple-kvvm #2
Conversation
vm/prefix/prefix.go
Outdated
| infoPrefix = 0x0 | ||
| keyPrefix = 0x1 | ||
| txPrefix = 0x2 | ||
| delimiter = 0x7 |
There was a problem hiding this comment.
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.
vm/prefix/prefix.go
Outdated
| "github.com/ava-labs/quarkvm/vm/codec" | ||
| ) | ||
|
|
||
| // 0x0/ (singleton prefix info) |
There was a problem hiding this comment.
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.
vm/transaction/transaction.go
Outdated
| return err | ||
| } | ||
| return db.Put(PrefixTxKey(t.ID()), nil) | ||
| return db.Put(prefix.TxKey(t.ID()), nil) |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)
c18cdbd to
14b2529
Compare
Signed-off-by: Gyuho Lee <[email protected]>
No description provided.