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

Can not apply transactions with incremented nonce when NoPrefetch=false #19723

Closed
ramilexe opened this issue Jun 17, 2019 · 3 comments
Closed
Assignees

Comments

@ramilexe
Copy link

When I was working on PR #19721 found a bug with NoPrefetch parameter in config:

Without NoPrefetch: true (line 188)

n.Register(func(ctx *node.ServiceContext) (node.Service, error) {
config := &eth.Config{Genesis: genesis, NoPrefetch: true}
config.Ethash.PowMode = ethash.ModeFake
ethservice, err = eth.New(ctx, config)
return ethservice, err
})

When I try to add 2 consecutive transactions with nonce 0 and 1 (line 240 and 247):

generate := func(i int, g *core.BlockGen) {
g.OffsetTime(5)
g.SetExtra([]byte("test"))
switch i {
case 0:
tx, err := types.SignTx(types.NewTransaction(g.TxNonce(testAddr), common.HexToAddress("0x1"), big.NewInt(1), 21000, big.NewInt(1), nil), signer, testKey)
if err != nil {
t.Fatal(err)
}
g.AddTx(tx)
case 1:
tx, err := types.SignTx(types.NewTransaction(g.TxNonce(testAddr), common.HexToAddress("0x2"), big.NewInt(2), 21000, big.NewInt(1), nil), signer, testKey)
if err != nil {
t.Fatal(err)
}
g.AddTx(tx)
}
}

I get error nonce too high on line 172:

func (st *StateTransition) preCheck() error {
// Make sure this transaction's nonce is correct.
if st.msg.CheckNonce() {
nonce := st.state.GetNonce(st.msg.From())
if nonce < st.msg.Nonce() {
return ErrNonceTooHigh
} else if nonce > st.msg.Nonce() {
return ErrNonceTooLow
}
}
return st.buyGas()
}

I think it related to #19328

/cc @karalabe @holiman

@holiman
Copy link
Contributor

holiman commented Jun 18, 2019

I guess it doesn't make sense to have prefetch=true on tests that do not actually process blocks properly, but it would be good to have @karalabe check that there isn't some deeper issue here.

@karalabe
Copy link
Member

This is an odd one. Prefetching should run the next block in advance, which in this case will genuinely fail... but that failure should never bubble up outside, since we're only doing it to pre-load data, we don't actually keep the execution result.

@ramilexe Do you actually hit an error, or are you just pondering about what's happening under the hood?

@stale
Copy link

stale bot commented Jun 20, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Aug 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@karalabe @holiman @ramilexe and others