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

Add Parlia consensus engine for Binance Smart Chain support #3086

Merged
merged 20 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix go fmt issues
  • Loading branch information
brendan-kelly committed Dec 10, 2021
commit c32504dac1e445efd96c03594a15e7a9fb337b7e
13 changes: 6 additions & 7 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"time"

lru "github.com/hashicorp/golang-lru"
"golang.org/x/crypto/sha3"
"github.com/ledgerwatch/erigon-lib/kv"
"golang.org/x/crypto/sha3"

"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon"
Expand All @@ -26,9 +26,9 @@ import (
"github.com/ledgerwatch/erigon/consensus"
"github.com/ledgerwatch/erigon/consensus/misc"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/systemcontracts/parlia"
"github.com/ledgerwatch/erigon/core/forkid"
"github.com/ledgerwatch/erigon/core/state"
"github.com/ledgerwatch/erigon/core/systemcontracts/parlia"
"github.com/ledgerwatch/erigon/core/types"
"github.com/ledgerwatch/erigon/core/types/accounts"
"github.com/ledgerwatch/erigon/core/vm"
Expand Down Expand Up @@ -200,12 +200,11 @@ type Parlia struct {

signer types.Signer

val common.Address // Ethereum address of the signing key
signFn SignerFn // Signer function to authorize hashes with
signTxFn SignerTxFn
val common.Address // Ethereum address of the signing key
signFn SignerFn // Signer function to authorize hashes with
signTxFn SignerTxFn
signTxFnLegacy SignerTxFnLegacy


lock sync.RWMutex // Protects the signer fields

ethAPI *ethapi.PublicBlockChainAPI
Expand Down Expand Up @@ -1132,7 +1131,7 @@ func (p *Parlia) applyTransaction(
panic("Oops")
}
return expectedTx
} (initExpectedTx)
}(initExpectedTx)

expectedHash := p.signer.Hash(expectedTx)
if msg.From() == p.val && mining {
Expand Down
2 changes: 1 addition & 1 deletion core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*Executi
effectiveTip = cmath.Min256(st.tip, new(uint256.Int).Sub(st.gasFeeCap, st.evm.Context().BaseFee))
}
// consensus engine is parlia
st.state.AddBalance(st.evm.Context().Coinbase, new(uint256.Int).Mul(new(uint256.Int).SetUint64(st.gasUsed()), effectiveTip))
st.state.AddBalance(st.evm.Context().Coinbase, new(uint256.Int).Mul(new(uint256.Int).SetUint64(st.gasUsed()), effectiveTip))

return &ExecutionResult{
UsedGas: st.gasUsed(),
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

// Covalent change: Empty Backend interface used for PublicBlockChainAPI below
type Backend interface {}
type Backend interface{}

// Covalent change: This has been uncommented to be used for Parlia
// PublicBlockChainAPI provides an API to access the Ethereum blockchain.
Expand Down