Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feat/update snapshot pending state #111

Merged
merged 6 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func testAccessList(t *testing.T, client *rpc.Client) {
From: testAddr,
To: &common.Address{},
Gas: 21000,
GasPrice: big.NewInt(765625000),
GasPrice: big.NewInt(875000000),
Value: big.NewInt(1),
}
al, gas, vmErr, err := ec.CreateAccessList(context.Background(), msg)
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ func DoEstimateGas(ctx context.Context, b Backend, args TransactionArgs, blockNr
// EstimateGas returns an estimate of the amount of gas needed to execute the
// given transaction against the current pending block.
func (s *PublicBlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) {
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
if blockNrOrHash != nil {
bNrOrHash = *blockNrOrHash
}
Expand Down Expand Up @@ -1622,7 +1622,7 @@ type accessListResult struct {
// CreateAccessList creates a EIP-2930 type AccessList for the given transaction.
// Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain state.
func (s *PublicBlockChainAPI) CreateAccessList(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (*accessListResult, error) {
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
bNrOrHash := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
if blockNrOrHash != nil {
bNrOrHash = *blockNrOrHash
}
Expand Down
12 changes: 9 additions & 3 deletions miner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (env *environment) copy() *environment {
coinbase: env.coinbase,
header: types.CopyHeader(env.header),
receipts: copyReceipts(env.receipts),
till: env.till,
}
if env.gasPool != nil {
gasPool := *env.gasPool
Expand Down Expand Up @@ -535,7 +536,7 @@ func (w *worker) newWorkLoopEx(recommit time.Duration) {

// commitSimple just starts a new commitNewWork
commitSimple := func() {
if atomic.CompareAndSwapInt32(&busyMining, 0, 1) {
if wemixminer.AmPartner() && atomic.CompareAndSwapInt32(&busyMining, 0, 1) {
w.newWorkCh <- &newWorkReq{interrupt: nil, noempty: false, timestamp: time.Now().Unix()}
atomic.StoreInt32(&w.newTxs, 0)
atomic.StoreInt32(&busyMining, 0)
Expand Down Expand Up @@ -1268,8 +1269,6 @@ func (w *worker) commitTransactionsEx(env *environment, interrupt *int32, tstart

}

time.Sleep(time.Until(*env.till))

log.Debug("Block", "number", env.header.Number.Int64(), "elapsed", common.PrettyDuration(time.Since(tstart)), "txs", len(committedTxs))

return false
Expand Down Expand Up @@ -1769,6 +1768,13 @@ func (w *worker) commitEx(env *environment, interval func(), update bool, start
}
logs = append(logs, receipt.Logs...)
}

if update {
w.updateSnapshot(env)
update = false
}
time.Sleep(time.Until(*env.till))

if !wemixminer.IsPoW() {
if err = wemixminer.ReleaseMiningToken(sealedBlock.Number(), sealedBlock.Hash(), sealedBlock.ParentHash()); err != nil {
return err
Expand Down
Loading