Skip to content

Commit

Permalink
Merge pull request #43 from blocknative/1.1.0
Browse files Browse the repository at this point in the history
Merge v1.1.0
  • Loading branch information
JonathonJulian authored Nov 16, 2023
2 parents 94e8d5c + 1ec8d6a commit 3475305
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 81 deletions.
10 changes: 9 additions & 1 deletion builder/files/genesis-mainnet-v1.json

Large diffs are not rendered by default.

21 changes: 6 additions & 15 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) {
}
}

if header.WithdrawalsHash != nil {
header.WithdrawalsHash = nil

log.Warn("Bor does not support withdrawals", "number", header.Number)
}

if err := rlp.Encode(w, enc); err != nil {
panic("can't encode: " + err.Error())
}
Expand Down Expand Up @@ -387,11 +381,14 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head

// Verify that the gas limit is <= 2^63-1
gasCap := uint64(0x7fffffffffffffff)

if header.GasLimit > gasCap {
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap)
}

if header.WithdrawalsHash != nil {
return consensus.ErrUnexpectedWithdrawals
}

// All basic checks passed, verify cascading fields
return c.verifyCascadingFields(chain, header, parents)
}
Expand Down Expand Up @@ -823,10 +820,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
headerNumber := header.Number.Uint64()

if withdrawals != nil || header.WithdrawalsHash != nil {
// withdrawals = nil is not required because withdrawals are not used
header.WithdrawalsHash = nil

log.Warn("Bor does not support withdrawals", "number", headerNumber)
return
}

if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
Expand Down Expand Up @@ -904,10 +898,7 @@ func (c *Bor) FinalizeAndAssemble(ctx context.Context, chain consensus.ChainHead
headerNumber := header.Number.Uint64()

if withdrawals != nil || header.WithdrawalsHash != nil {
// withdrawals != nil not required because withdrawals are not used
header.WithdrawalsHash = nil

log.Warn("Bor does not support withdrawals", "number", headerNumber)
return nil, consensus.ErrUnexpectedWithdrawals
}

stateSyncData := []*types.StateSyncData{}
Expand Down
7 changes: 6 additions & 1 deletion consensus/bor/statefull/processor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package statefull

import (
"bytes"
"context"
"math"
"math/big"
Expand Down Expand Up @@ -90,7 +91,11 @@ func ApplyMessage(

success := big.NewInt(5).SetBytes(ret)

if success.Cmp(big.NewInt(0)) == 0 {
validatorContract := common.HexToAddress(chainConfig.Bor.ValidatorContract)

// if success == 0 and msg.To() != validatorContractAddress, log Error
// if msg.To() == validatorContractAddress, its committing a span and we don't get any return value
if success.Cmp(big.NewInt(0)) == 0 && !bytes.Equal(msg.To().Bytes(), validatorContract.Bytes()) {
log.Error("message execution failed on contract", "msgData", msg.Data)
}

Expand Down
3 changes: 3 additions & 0 deletions consensus/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ var (
// ErrInvalidTerminalBlock is returned if a block is invalid wrt. the terminal
// total difficulty.
ErrInvalidTerminalBlock = errors.New("invalid terminal block")

// ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals.
ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals")
)
15 changes: 9 additions & 6 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,15 @@ func newShanghaiInstructionSet() JumpTable {

func newMergeInstructionSet() JumpTable {
instructionSet := newLondonInstructionSet()
instructionSet[PREVRANDAO] = &operation{
execute: opRandom,
constantGas: GasQuickStep,
minStack: minStack(0, 1),
maxStack: maxStack(0, 1),
}

// disabling in pos due to incompatibility with prevrandao

// instructionSet[PREVRANDAO] = &operation{
// execute: opRandom,
// constantGas: GasQuickStep,
// minStack: minStack(0, 1),
// maxStack: maxStack(0, 1),
// }

return validate(instructionSet)
}
Expand Down
14 changes: 1 addition & 13 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,6 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
// Call Prepare to clear out the statedb access list
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)

var result *core.ExecutionResult

if config.BorTx == nil {
config.BorTx = newBoolPtr(false)
}
Expand All @@ -1414,17 +1412,7 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
// Depending on the tracer type, format and return the output.
switch tracer := tracer.(type) {
case *logger.StructLogger:
// If the result contains a revert reason, return it.
returnVal := fmt.Sprintf("%x", result.Return())
if len(result.Revert()) > 0 {
returnVal = fmt.Sprintf("%x", result.Revert())
}
return &ethapi.ExecutionResult{
Gas: result.UsedGas,
Failed: result.Failed(),
ReturnValue: returnVal,
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
}, nil
return tracer.GetResult()

case Tracer:
return tracer.GetResult()
Expand Down
8 changes: 8 additions & 0 deletions internal/cli/server/chains/mainnet.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion internal/ethapi/transaction_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
return nil
}

func (b *backendMock) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
return nil
}

func (b *backendMock) Engine() consensus.Engine { return nil }

func (b *backendMock) RPCRpcReturnDataLimit() uint64 {
Expand All @@ -380,7 +384,7 @@ func (b *backendMock) GetVoteOnHash(ctx context.Context, starBlockNr uint64, end
}

func (b *backendMock) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
//nolint: nilnil
// nolint: nilnil
return nil, nil
}

Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
3 changes: 1 addition & 2 deletions packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand All @@ -10,4 +10,3 @@ Architecture: arm64
Multi-Arch: foreign
Depends:
Description: This is the bor package from Polygon Technology.

4 changes: 1 addition & 3 deletions packaging/templates/package_scripts/control.profile.amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand All @@ -10,5 +10,3 @@ Architecture: amd64
Multi-Arch: foreign
Depends:
Description: This is the bor package from Polygon Technology.


2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.validator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
3 changes: 1 addition & 2 deletions packaging/templates/package_scripts/control.validator.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.1.0-beta3
Version: 1.1.0
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand All @@ -10,4 +10,3 @@ Architecture: arm64
Multi-Arch: foreign
Depends:
Description: This is the bor package from Polygon Technology.

52 changes: 23 additions & 29 deletions params/config.go

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions params/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"
"time"

"gotest.tools/assert"

"github.com/ethereum/go-ethereum/common/math"
)

Expand Down Expand Up @@ -134,3 +136,45 @@ func TestConfigRules(t *testing.T) {
t.Errorf("expected %v to be shanghai", 0)
}
}

func TestBorKeyValueConfigHelper(t *testing.T) {
t.Parallel()

backupMultiplier := map[string]uint64{
"0": 2,
"25275000": 5,
"29638656": 2,
}
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 0), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 1), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000-1), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000), uint64(5))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000+1), uint64(5))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656-1), uint64(5))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656+1), uint64(2))

config := map[string]uint64{
"0": 1,
"90000000": 2,
"100000000": 3,
}
assert.Equal(t, borKeyValueConfigHelper(config, 0), uint64(1))
assert.Equal(t, borKeyValueConfigHelper(config, 1), uint64(1))
assert.Equal(t, borKeyValueConfigHelper(config, 90000000-1), uint64(1))
assert.Equal(t, borKeyValueConfigHelper(config, 90000000), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(config, 90000000+1), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(config, 100000000-1), uint64(2))
assert.Equal(t, borKeyValueConfigHelper(config, 100000000), uint64(3))
assert.Equal(t, borKeyValueConfigHelper(config, 100000000+1), uint64(3))

burntContract := map[string]string{
"22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38",
"41824608": "0x617b94CCCC2511808A3C9478ebb96f455CF167aA",
}
assert.Equal(t, borKeyValueConfigHelper(burntContract, 22640000), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
assert.Equal(t, borKeyValueConfigHelper(burntContract, 22640000+1), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608-1), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA")
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608+1), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA")
}
8 changes: 4 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
)

const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "beta3" // Version metadata to append to the version string
VersionMajor = 1 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)

var GitCommit string
Expand Down
6 changes: 5 additions & 1 deletion tests/bor/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
ctx := context.Background()

// Finalize and seal the block
block, _ := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts, []*types.Withdrawal{})
block, err := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts, nil)

if err != nil {
panic(fmt.Sprintf("error finalizing block: %v", err))
}

// Write state changes to db
root, err := state.Commit(chain.Config().IsEIP158(b.header.Number))
Expand Down

0 comments on commit 3475305

Please sign in to comment.