Skip to content
New issue

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

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

Already on GitHub? Sign in 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 4 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
2 changes: 1 addition & 1 deletion graphql/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ func (p *Pending) Call(ctx context.Context, args struct {
func (p *Pending) EstimateGas(ctx context.Context, args struct {
Data ethapi.TransactionArgs
}) (Long, error) {
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber)
pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
jennwiederholen marked this conversation as resolved.
Show resolved Hide resolved
gas, err := ethapi.DoEstimateGas(ctx, p.backend, args.Data, pendingBlockNr, p.backend.RPCGasCap())
return Long(gas), err
}
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
13 changes: 10 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 @@ -598,8 +599,10 @@ func (w *worker) mainLoop() {
// In wemix, costly interrupt / resubmit is disabled
if wemixminer.IsPoW() {
w.commitWork(req.interrupt, req.noempty, req.timestamp)
} else {
} else if wemixminer.AmPartner() {
jennwiederholen marked this conversation as resolved.
Show resolved Hide resolved
w.commitWork(nil, req.noempty, req.timestamp)
} else {
w.refreshPending(true)
}

case req := <-w.getWorkCh:
Expand Down Expand Up @@ -1268,8 +1271,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 +1770,12 @@ func (w *worker) commitEx(env *environment, interval func(), update bool, start
}
logs = append(logs, receipt.Logs...)
}

if update {
w.updateSnapshot(env)
jennwiederholen marked this conversation as resolved.
Show resolved Hide resolved
}
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