-
Notifications
You must be signed in to change notification settings - Fork 28
Work Units Overhaul #20
Conversation
a640220 to
f0ddd33
Compare
|
We may have more luck doing more granular control on difficulty (using an int instead of bits). I think the multi-work thing is somewhat jank...will change to continuous work calculation to avoid 2^x forced granularity. |
| k[0] = p | ||
| k[1] = parser.Delimiter | ||
| binary.LittleEndian.PutUint64(k[2:], uint64(t)) | ||
| binary.BigEndian.PutUint64(k[2:], t) |
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.
Found this pretty serious bug in my code lol
6ffbbdf to
0ad71d8
Compare
Block builds are failing, causing e2e test failures. |
Signed-off-by: Gyuho Lee <[email protected]>
b22933b to
0a0efb3
Compare
|
Latest Clues: fetched estimated difficulty (diff=7, cost=1)
issuing tx 2Rgg8ZnhvgJBRr5ixAYRZARb4zBEpJR1D4kDjgGLPE7qrwMavz (units=10, difficulty=9, surplus=20, blkID=Y9UdWfUz6uUyAqjAXspoSEvA4BfbYe62m5VyenZWrMExFUdFh)
transaction 2Rgg8ZnhvgJBRr5ixAYRZARb4zBEpJR1D4kDjgGLPE7qrwMavz confirmed
raw prefix P55X8AD2z7ugaoB8BQsu27jDhpqTAsczP: units=1 expiry=2022-02-08 02:13:27 +0000 UTC (719h59m58.545538054s remaining)
fetched estimated difficulty (diff=6, cost=60)
issuing tx msN8k866zjv5hJP3qJHh66EA3KP64fr5W8Mc8ZS8vLkBUaCFp (units=11, difficulty=344, surplus=3718, blkID=WM5fUVnnEdKg73mb3ivsurvQ3Rx9kzmWSW1EvjLN1JsyK2tD7)
transaction msN8k866zjv5hJP3qJHh66EA3KP64fr5W8Mc8ZS8vLkBUaCFp confirmed
raw prefix P55X8AD2z7ugaoB8BQsu27jDhpqTAsczP: units=2 expiry=2022-01-24 02:13:28 +0000 UTC (359h59m58.223977384s remaining)
fetched estimated difficulty (diff=5, cost=59)
issuing tx 2X5uQfgjTgqNCSZL5XCmsM4Hww9ByBEgA4kt2vx9h6WoG9rsTo (units=31, difficulty=14, surplus=279, blkID=2AJTt9UuYGfMnFWGhmDp7Rc9KADhd86Wgx52GnPBsSn7U3rPR) |
|
From the node: |
| return nil, nil, err | ||
| } | ||
| surplusWork += (tx.Difficulty() - context.NextDifficulty) * tx.Units() | ||
| surplusWork += (tx.Difficulty() - b.Difficulty) * tx.Units() |
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.
ah good catch!
| recommendedC := ctx.NextCost / uint64(recentTxs) | ||
| if recommendedC < vm.minBlockCost { | ||
| recommendedC = vm.minBlockCost | ||
| cPerTx := pCost / uint64(recentTxs) / uint64(ctx.RecentBlockIDs.Len()) |
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.
Here recentTxs == ctx.RecentBlockIDs.Len() via line 83? Why do we do division twice?
And can ctx.RecentTxIDs.Len() be ever 0 (zero devision panic)?
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 check that
recentTxsis non-zero on 83 to prevent div by 0 (could happen in block height 1) - recent block ids can never be 0
| } | ||
|
|
||
| func PutPrefixInfo(db database.KeyValueWriter, prefix []byte, i *PrefixInfo, lastExpiry int64) error { | ||
| func PutPrefixInfo(db database.KeyValueWriter, prefix []byte, i *PrefixInfo, lastExpiry uint64) 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.
+1
chain/storage.go
Outdated
| cursor := db.NewIteratorWithStart(startKey) | ||
| removals := 0 | ||
| for cursor.Next() && removals < limit { | ||
| for cursor.Next() && removals <= limit { |
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.
removals < limit
since this can delete limit + 1?
If we want to adjust prune interval to fullPruneInterval of 1-second on removals=true, vm.pruneCall() can set removals=true when removals >= vm.pruneLimit, or change this for-loop to removals < limit and keep removals == vm.pruneLimit?
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.
Whoops...reverted that change.
To allow for larger values, we gotta get a little creative 😉 . Multiple units of work can now be completed in a given transaction (as a function of graffitis).
Right now, this PR makes it so you can differentiate the cost to set a large key vs the rate it decays at.