From c2c48b2dfd92ca35d472daf99795ef5edad85be0 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 26 Sep 2024 10:50:25 +0800 Subject: [PATCH 1/4] fix eth_getTransactionReceipt --- consensus/parlia/parlia.go | 6 +++--- core/state_transition.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index da8089e1889..27d4eb57ae2 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -1269,13 +1269,13 @@ func (p *Parlia) IsSystemTransaction(tx types.Transaction, header *types.Header) if err != nil { return false, errors.New("UnAuthorized transaction") } - if sender == header.Coinbase && isToSystemContract(*tx.GetTo()) && tx.GetPrice().IsZero() { + if sender == header.Coinbase && IsToSystemContract(*tx.GetTo()) && tx.GetPrice().IsZero() { return true, nil } return false, nil } -func isToSystemContract(to libcommon.Address) bool { +func IsToSystemContract(to libcommon.Address) bool { _, ok := systemContracts[to] return ok } @@ -1284,7 +1284,7 @@ func (p *Parlia) IsSystemContract(to *libcommon.Address) bool { if to == nil { return false } - return isToSystemContract(*to) + return IsToSystemContract(*to) } func (p *Parlia) EnoughDistance(chain consensus.ChainReader, header *types.Header) bool { diff --git a/core/state_transition.go b/core/state_transition.go index d79c356cf6a..83ec15ed0c2 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -24,6 +24,7 @@ import ( "errors" "fmt" "github.com/erigontech/erigon/consensus" + "github.com/erigontech/erigon/consensus/parlia" "math" "slices" @@ -335,7 +336,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype // BSC always gave gas bailout due to system transactions that set 2^256/2 gas limit and // So when trace systemTx, skip PreCheck var skipCheck bool - if st.isParlia && st.evm.Config().Debug && st.msg.Gas() == math.MaxUint64/2 { + if st.isParlia && st.msg.Gas() == math.MaxUint64/2 && st.gasPrice == uint256.NewInt(0) && parlia.IsToSystemContract(*st.msg.To()) { skipCheck = true } From 0191f8eb22c47c7d63b6435fb5dc68f6399e10c0 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 26 Sep 2024 10:57:43 +0800 Subject: [PATCH 2/4] fix eth_getTransactionReceipt --- consensus/parlia/parlia.go | 6 +++--- core/state_transition.go | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/consensus/parlia/parlia.go b/consensus/parlia/parlia.go index 27d4eb57ae2..da8089e1889 100644 --- a/consensus/parlia/parlia.go +++ b/consensus/parlia/parlia.go @@ -1269,13 +1269,13 @@ func (p *Parlia) IsSystemTransaction(tx types.Transaction, header *types.Header) if err != nil { return false, errors.New("UnAuthorized transaction") } - if sender == header.Coinbase && IsToSystemContract(*tx.GetTo()) && tx.GetPrice().IsZero() { + if sender == header.Coinbase && isToSystemContract(*tx.GetTo()) && tx.GetPrice().IsZero() { return true, nil } return false, nil } -func IsToSystemContract(to libcommon.Address) bool { +func isToSystemContract(to libcommon.Address) bool { _, ok := systemContracts[to] return ok } @@ -1284,7 +1284,7 @@ func (p *Parlia) IsSystemContract(to *libcommon.Address) bool { if to == nil { return false } - return IsToSystemContract(*to) + return isToSystemContract(*to) } func (p *Parlia) EnoughDistance(chain consensus.ChainReader, header *types.Header) bool { diff --git a/core/state_transition.go b/core/state_transition.go index 83ec15ed0c2..f5bdfff1840 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -24,7 +24,6 @@ import ( "errors" "fmt" "github.com/erigontech/erigon/consensus" - "github.com/erigontech/erigon/consensus/parlia" "math" "slices" @@ -336,7 +335,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype // BSC always gave gas bailout due to system transactions that set 2^256/2 gas limit and // So when trace systemTx, skip PreCheck var skipCheck bool - if st.isParlia && st.msg.Gas() == math.MaxUint64/2 && st.gasPrice == uint256.NewInt(0) && parlia.IsToSystemContract(*st.msg.To()) { + if st.isParlia && st.msg.Gas() == math.MaxUint64/2 && st.gasPrice == uint256.NewInt(0) { skipCheck = true } From 2c9e85ec3d2f7900c561b9a9f3fe2bd06ba2913b Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 26 Sep 2024 11:08:42 +0800 Subject: [PATCH 3/4] fix eth_getTransactionReceipt --- core/state_transition.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/state_transition.go b/core/state_transition.go index f5bdfff1840..c763432ac47 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -229,7 +229,9 @@ func (st *StateTransition) buyGas(gasBailout bool) error { } if err := st.gp.SubGas(st.msg.Gas()); err != nil { - return err + if !gasBailout { + return err + } } st.gasRemaining += st.msg.Gas() st.initialGas = st.msg.Gas() From 87fea2fcf3f8f63c2eac4433e5e83efb29960b66 Mon Sep 17 00:00:00 2001 From: blxdyx Date: Thu, 26 Sep 2024 11:34:00 +0800 Subject: [PATCH 4/4] fix eth_getTransactionReceipt --- core/state_transition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/state_transition.go b/core/state_transition.go index c763432ac47..b82a18eaab7 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -337,7 +337,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype // BSC always gave gas bailout due to system transactions that set 2^256/2 gas limit and // So when trace systemTx, skip PreCheck var skipCheck bool - if st.isParlia && st.msg.Gas() == math.MaxUint64/2 && st.gasPrice == uint256.NewInt(0) { + if st.isParlia && st.msg.Gas() == math.MaxUint64/2 && st.gasPrice.IsZero() { skipCheck = true }