Skip to content

Commit

Permalink
Merge pull request ledgerwatch#7 from testinprod-io/tei/sync-errors
Browse files Browse the repository at this point in the history
Fix sync errors
  • Loading branch information
ImTei committed Feb 24, 2023
2 parents a339a23 + c431981 commit d4dd6cd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion cmd/rpcdaemon/commands/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ type RPCTransaction struct {
BlockNumber *hexutil.Big `json:"blockNumber"`
From common.Address `json:"from"`
Gas hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
GasPrice *hexutil.Big `json:"gasPrice"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
Hash common.Hash `json:"hash"`
Expand Down Expand Up @@ -396,6 +396,7 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
if t.Mint != nil {
result.Mint = (*hexutil.Big)(t.Mint.ToBig())
}
result.ChainID = nil
result.SourceHash = &t.SourceHash
result.IsSystemTx = &t.IsSystemTransaction
}
Expand Down
3 changes: 1 addition & 2 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package core

import (
"fmt"

"github.com/holiman/uint256"
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/txpool"
Expand Down Expand Up @@ -334,7 +333,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*Executi
result, err := st.innerTransitionDb(refunds, gasBailout)
// Failed deposits must still be included. Unless we cannot produce the block at all due to the gas limit.
// On deposit failure, we rewind any state changes from after the minting, and increment the nonce.
if err != nil && err != ErrGasLimitReached && st.msg.IsDepositTx() {
if ((result != nil && result.Err != nil) || (err != nil && err != ErrGasLimitReached)) && st.msg.IsDepositTx() {
st.state.RevertToSnapshot(snap)
// Even though we revert the state changes, always increment the nonce for the next deposit transaction
st.state.SetNonce(st.msg.From(), st.state.GetNonce(st.msg.From())+1)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.18

//fork with minor protobuf file changes and txpool support
replace github.com/ledgerwatch/erigon-lib v0.0.0-20230201215037-1a14cfd7e764 => github.com/testinprod-io/erigon-lib v0.0.0-20230223054532-47348944d20f
replace github.com/ledgerwatch/erigon-lib v0.0.0-20230201215037-1a14cfd7e764 => github.com/testinprod-io/erigon-lib v0.0.0-20230224141120-425e3963f8fb

//for local dev:
//replace github.com/ledgerwatch/erigon-lib v0.0.0-20230201215037-1a14cfd7e764 => ../erigon-lib
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,8 @@ github.com/supranational/blst v0.3.10/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
github.com/tendermint/go-amino v0.14.1 h1:o2WudxNfdLNBwMyl2dqOJxiro5rfrEaU0Ugs6offJMk=
github.com/tendermint/go-amino v0.14.1/go.mod h1:i/UKE5Uocn+argJJBb12qTZsCDBcAYMbR92AaJVmKso=
github.com/testinprod-io/erigon-lib v0.0.0-20230223054532-47348944d20f h1:o/vSG2NxL7kJj9X+721X1jDhwIazlojSKm5qjWO4Ek8=
github.com/testinprod-io/erigon-lib v0.0.0-20230223054532-47348944d20f/go.mod h1:eyzE686+0USrkuiq6Obfh5uNtyADbr/3TOjSxTdEnaE=
github.com/testinprod-io/erigon-lib v0.0.0-20230224141120-425e3963f8fb h1:KfcxBaUmip9TO8HxuNccAGgmLzWkaRCMK9nmu1/LVZM=
github.com/testinprod-io/erigon-lib v0.0.0-20230224141120-425e3963f8fb/go.mod h1:eyzE686+0USrkuiq6Obfh5uNtyADbr/3TOjSxTdEnaE=
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e h1:cR8/SYRgyQCt5cNCMniB/ZScMkhI9nk8U5C7SbISXjo=
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e/go.mod h1:Tu4lItkATkonrYuvtVjG0/rhy15qrNGNTjPdaphtZ/8=
github.com/tidwall/btree v1.5.0 h1:iV0yVY/frd7r6qGBXfEYs7DH0gTDgrKTrDjS7xt/IyQ=
Expand Down
13 changes: 6 additions & 7 deletions turbo/adapter/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ type RPCTransaction struct {
BlockNumber *hexutil.Big `json:"blockNumber"`
From libcommon.Address `json:"from"`
Gas hexutil.Uint64 `json:"gas"`
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
GasPrice *hexutil.Big `json:"gasPrice"`
Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
Hash libcommon.Hash `json:"hash"`
Expand All @@ -387,9 +387,9 @@ type RPCTransaction struct {
R *hexutil.Big `json:"r"`
S *hexutil.Big `json:"s"`
// deposit-tx only
SourceHash libcommon.Hash `json:"sourceHash,omitempty"`
Mint *hexutil.Big `json:"mint,omitempty"`
IsSystemTx bool `json:"isSystemTx,omitempty"`
SourceHash *libcommon.Hash `json:"sourceHash,omitempty"`
Mint *hexutil.Big `json:"mint,omitempty"`
IsSystemTx bool `json:"isSystemTx,omitempty"`
}

// newRPCTransaction returns a transaction that will serialize to the RPC
Expand Down Expand Up @@ -446,12 +446,11 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
result.GasPrice = nil
}
case *types.DepositTx:
chainId = uint256.NewInt(0)
result.ChainID = (*hexutil.Big)(chainId.ToBig())
if t.Mint != nil {
result.Mint = (*hexutil.Big)(t.Mint.ToBig())
}
result.SourceHash = t.SourceHash
result.ChainID = nil
result.SourceHash = &t.SourceHash
result.IsSystemTx = t.IsSystemTransaction
}
signer := types.LatestSignerForChainID(chainId.ToBig())
Expand Down

0 comments on commit d4dd6cd

Please sign in to comment.