mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-04 15:55:23 +00:00
Compare commits
No commits in common. "2c436a7d45262da7456a9d82cd576e79bbebb199" and "2cc584be0b00e959739ca08842ccca5ce2708988" have entirely different histories.
2c436a7d45
...
2cc584be0b
24
app/app.go
24
app/app.go
@ -1085,30 +1085,14 @@ func NewAccountNonceOp(app *App) AccountNonceOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ano *accountNonceOp) GetAccountNonce(ctx sdk.Context, address string) uint64 {
|
func (ano *accountNonceOp) GetAccountNonce(ctx sdk.Context, address string) uint64 {
|
||||||
bzAcc, err := sdk.AccAddressFromBech32(address)
|
bzAcc, _ := sdk.AccAddressFromBech32(address)
|
||||||
if err != nil {
|
|
||||||
ctx.Logger().Error("GetAccountNonce: failed to parse address", "address", address, "error", err)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
acc := ano.ak.GetAccount(ctx, bzAcc)
|
acc := ano.ak.GetAccount(ctx, bzAcc)
|
||||||
if acc == nil {
|
|
||||||
ctx.Logger().Error("GetAccountNonce: account not found", "address", address)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return acc.GetSequence()
|
return acc.GetSequence()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ano *accountNonceOp) SetAccountNonce(ctx sdk.Context, address string, nonce uint64) {
|
func (ano *accountNonceOp) SetAccountNonce(ctx sdk.Context, address string, nonce uint64) {
|
||||||
bzAcc, err := sdk.AccAddressFromBech32(address)
|
bzAcc, _ := sdk.AccAddressFromBech32(address)
|
||||||
if err != nil {
|
|
||||||
ctx.Logger().Error("SetAccountNonce: failed to parse address", "address", address, "nonce", nonce, "error", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
acc := ano.ak.GetAccount(ctx, bzAcc)
|
acc := ano.ak.GetAccount(ctx, bzAcc)
|
||||||
if acc != nil {
|
acc.SetSequence(nonce)
|
||||||
acc.SetSequence(nonce)
|
ano.ak.SetAccount(ctx, acc)
|
||||||
ano.ak.SetAccount(ctx, acc)
|
|
||||||
} else {
|
|
||||||
ctx.Logger().Error("SetAccountNonce: account not found", "address", address)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ func (mp *PriorityNonceMempool) Insert(ctx context.Context, tx sdk.Tx) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if indexSize > 0 {
|
if indexSize > 1 {
|
||||||
tail := index.Back()
|
tail := index.Back()
|
||||||
if tail != nil {
|
if tail != nil {
|
||||||
tailKey := tail.Key().(txMeta)
|
tailKey := tail.Key().(txMeta)
|
||||||
@ -291,6 +291,8 @@ func (mp *PriorityNonceMempool) Insert(ctx context.Context, tx sdk.Tx) error {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// not found any index more than 1 except sender's index
|
||||||
|
// We do not replace the sender's only tx in the mempool
|
||||||
return errors.Wrapf(errMempoolIsFull, "%d@%s with priority%d", newKey.nonce, newKey.sender, newKey.priority)
|
return errors.Wrapf(errMempoolIsFull, "%d@%s with priority%d", newKey.nonce, newKey.sender, newKey.priority)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -137,12 +137,8 @@ func (ac appCreator) newApp(
|
|||||||
sdkContext := sdk.UnwrapSDKContext(ctx)
|
sdkContext := sdk.UnwrapSDKContext(ctx)
|
||||||
if accountNonceOp != nil {
|
if accountNonceOp != nil {
|
||||||
nonce := accountNonceOp.GetAccountNonce(sdkContext, oldTx.Sender)
|
nonce := accountNonceOp.GetAccountNonce(sdkContext, oldTx.Sender)
|
||||||
if nonce > 0 {
|
accountNonceOp.SetAccountNonce(sdkContext, oldTx.Sender, nonce-1)
|
||||||
accountNonceOp.SetAccountNonce(sdkContext, oldTx.Sender, nonce-1)
|
sdkContext.Logger().Debug("rewind the nonce of the account", "account", oldTx.Sender, "from", nonce, "to", nonce-1)
|
||||||
sdkContext.Logger().Debug("rewind the nonce of the account", "account", oldTx.Sender, "from", nonce, "to", nonce-1)
|
|
||||||
} else {
|
|
||||||
sdkContext.Logger().Info("First meeting account", "account", oldTx.Sender)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sdkContext := sdk.UnwrapSDKContext(ctx)
|
sdkContext := sdk.UnwrapSDKContext(ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user