Skip to content

Commit

Permalink
feat: mev-builder
Browse files Browse the repository at this point in the history
* consesus: add a interface to set validator at runtime
* core/txpool: add bundlepool to maintain bundle txs
* core/type: define bundle
* internal/ethapi: add sendBundle, bundlePrice, unregis
* ethclient: add SendBundle
* miner: add fillTransacitonsAndBundles, add Bidder to sendBid to validators
* add README.builder.md
  • Loading branch information
raina authored and irrun committed Mar 12, 2024
1 parent 7169e2b commit 732993e
Show file tree
Hide file tree
Showing 26 changed files with 1,848 additions and 35 deletions.
42 changes: 42 additions & 0 deletions README.builder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[bsc readme](README.original.md)

# BSC Builder

This project implements the BEP-322: Builder API Specification for BNB Smart Chain.

This project represents a minimal implementation of the protocol and is provided as is. We make no guarantees regarding its functionality or security.

See also: https://github.com/bnb-chain/BEPs/pull/322

# Usage

Builder-related settings are configured in the `config.toml` file. The following is an example of a `config.toml` file:

```
[Eth.Miner.Bidder]
Enable = true
Account = {{BUILDER_ADDRESS}}
DelayLeftOver = {{DELAY_LEFT_OVER}}
[[Eth.Miner.Bidder.Validators]]
Address = {{VALIDATOR_ADDRESS}}
URL = {{VALIDATOR_URL}}
...
```

- `Enable`: Whether to enable the builder.
- `Account`: The account address to unlock of the builder.
- `DelayLeftOver`: Submit bid no later than `DelayLeftOver` before the next block time.
- `Validators`: A list of validators to bid for.
- `Address`: The address of the validator.
- `URL`: The URL of the validator.

## License

The bsc library (i.e. all code outside of the `cmd` directory) is licensed under the
[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html),
also included in our repository in the `COPYING.LESSER` file.

The bsc binaries (i.e. all code inside of the `cmd` directory) is licensed under the
[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also
included in our repository in the `COPYING` file.
1 change: 1 addition & 0 deletions consensus/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,5 @@ type PoSA interface {
GetFinalizedHeader(chain ChainHeaderReader, header *types.Header) *types.Header
VerifyVote(chain ChainHeaderReader, vote *types.VoteEnvelope) error
IsActiveValidatorAt(chain ChainHeaderReader, header *types.Header, checkVoteKeyFn func(bLSPublicKey *types.BLSPublicKey) bool) bool
SetValidator(validator common.Address)
}
11 changes: 11 additions & 0 deletions consensus/parlia/parlia.go
Original file line number Diff line number Diff line change
Expand Up @@ -1878,6 +1878,17 @@ func (p *Parlia) GetFinalizedHeader(chain consensus.ChainHeaderReader, header *t
return chain.GetHeader(snap.Attestation.SourceHash, snap.Attestation.SourceNumber)
}

// SetValidator set the validator of parlia engine
// It is used for builder
func (p *Parlia) SetValidator(val common.Address) {
if val == (common.Address{}) {
return
}
p.lock.Lock()
defer p.lock.Unlock()
p.val = val
}

// =========================== utility function ==========================
func (p *Parlia) backOffTime(snap *Snapshot, header *types.Header, val common.Address) uint64 {
if snap.inturn(val) {
Expand Down
Loading

0 comments on commit 732993e

Please sign in to comment.