Skip to content

Commit 3475305

Browse files
Merge pull request #43 from blocknative/1.1.0
Merge v1.1.0
2 parents 94e8d5c + 1ec8d6a commit 3475305

File tree

18 files changed

+129
-81
lines changed

18 files changed

+129
-81
lines changed

builder/files/genesis-mainnet-v1.json

+9-1
Large diffs are not rendered by default.

consensus/bor/bor.go

+6-15
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ func encodeSigHeader(w io.Writer, header *types.Header, c *params.BorConfig) {
172172
}
173173
}
174174

175-
if header.WithdrawalsHash != nil {
176-
header.WithdrawalsHash = nil
177-
178-
log.Warn("Bor does not support withdrawals", "number", header.Number)
179-
}
180-
181175
if err := rlp.Encode(w, enc); err != nil {
182176
panic("can't encode: " + err.Error())
183177
}
@@ -387,11 +381,14 @@ func (c *Bor) verifyHeader(chain consensus.ChainHeaderReader, header *types.Head
387381

388382
// Verify that the gas limit is <= 2^63-1
389383
gasCap := uint64(0x7fffffffffffffff)
390-
391384
if header.GasLimit > gasCap {
392385
return fmt.Errorf("invalid gasLimit: have %v, max %v", header.GasLimit, gasCap)
393386
}
394387

388+
if header.WithdrawalsHash != nil {
389+
return consensus.ErrUnexpectedWithdrawals
390+
}
391+
395392
// All basic checks passed, verify cascading fields
396393
return c.verifyCascadingFields(chain, header, parents)
397394
}
@@ -823,10 +820,7 @@ func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header,
823820
headerNumber := header.Number.Uint64()
824821

825822
if withdrawals != nil || header.WithdrawalsHash != nil {
826-
// withdrawals = nil is not required because withdrawals are not used
827-
header.WithdrawalsHash = nil
828-
829-
log.Warn("Bor does not support withdrawals", "number", headerNumber)
823+
return
830824
}
831825

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

906900
if withdrawals != nil || header.WithdrawalsHash != nil {
907-
// withdrawals != nil not required because withdrawals are not used
908-
header.WithdrawalsHash = nil
909-
910-
log.Warn("Bor does not support withdrawals", "number", headerNumber)
901+
return nil, consensus.ErrUnexpectedWithdrawals
911902
}
912903

913904
stateSyncData := []*types.StateSyncData{}

consensus/bor/statefull/processor.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package statefull
22

33
import (
4+
"bytes"
45
"context"
56
"math"
67
"math/big"
@@ -90,7 +91,11 @@ func ApplyMessage(
9091

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

93-
if success.Cmp(big.NewInt(0)) == 0 {
94+
validatorContract := common.HexToAddress(chainConfig.Bor.ValidatorContract)
95+
96+
// if success == 0 and msg.To() != validatorContractAddress, log Error
97+
// if msg.To() == validatorContractAddress, its committing a span and we don't get any return value
98+
if success.Cmp(big.NewInt(0)) == 0 && !bytes.Equal(msg.To().Bytes(), validatorContract.Bytes()) {
9499
log.Error("message execution failed on contract", "msgData", msg.Data)
95100
}
96101

consensus/errors.go

+3
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ var (
3838
// ErrInvalidTerminalBlock is returned if a block is invalid wrt. the terminal
3939
// total difficulty.
4040
ErrInvalidTerminalBlock = errors.New("invalid terminal block")
41+
42+
// ErrUnexpectedWithdrawals is returned if a pre-Shanghai block has withdrawals.
43+
ErrUnexpectedWithdrawals = errors.New("unexpected withdrawals")
4144
)

core/vm/jump_table.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,15 @@ func newShanghaiInstructionSet() JumpTable {
9090

9191
func newMergeInstructionSet() JumpTable {
9292
instructionSet := newLondonInstructionSet()
93-
instructionSet[PREVRANDAO] = &operation{
94-
execute: opRandom,
95-
constantGas: GasQuickStep,
96-
minStack: minStack(0, 1),
97-
maxStack: maxStack(0, 1),
98-
}
93+
94+
// disabling in pos due to incompatibility with prevrandao
95+
96+
// instructionSet[PREVRANDAO] = &operation{
97+
// execute: opRandom,
98+
// constantGas: GasQuickStep,
99+
// minStack: minStack(0, 1),
100+
// maxStack: maxStack(0, 1),
101+
// }
99102

100103
return validate(instructionSet)
101104
}

eth/tracers/api.go

+1-13
Original file line numberDiff line numberDiff line change
@@ -1392,8 +1392,6 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
13921392
// Call Prepare to clear out the statedb access list
13931393
statedb.SetTxContext(txctx.TxHash, txctx.TxIndex)
13941394

1395-
var result *core.ExecutionResult
1396-
13971395
if config.BorTx == nil {
13981396
config.BorTx = newBoolPtr(false)
13991397
}
@@ -1414,17 +1412,7 @@ func (api *API) traceTx(ctx context.Context, message *core.Message, txctx *Conte
14141412
// Depending on the tracer type, format and return the output.
14151413
switch tracer := tracer.(type) {
14161414
case *logger.StructLogger:
1417-
// If the result contains a revert reason, return it.
1418-
returnVal := fmt.Sprintf("%x", result.Return())
1419-
if len(result.Revert()) > 0 {
1420-
returnVal = fmt.Sprintf("%x", result.Revert())
1421-
}
1422-
return &ethapi.ExecutionResult{
1423-
Gas: result.UsedGas,
1424-
Failed: result.Failed(),
1425-
ReturnValue: returnVal,
1426-
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
1427-
}, nil
1415+
return tracer.GetResult()
14281416

14291417
case Tracer:
14301418
return tracer.GetResult()

internal/cli/server/chains/mainnet.go

+8
Large diffs are not rendered by default.

internal/ethapi/transaction_args_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ func (b *backendMock) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent)
361361
return nil
362362
}
363363

364+
func (b *backendMock) SubscribeDropTxsEvent(ch chan<- core.DropTxsEvent) event.Subscription {
365+
return nil
366+
}
367+
364368
func (b *backendMock) Engine() consensus.Engine { return nil }
365369

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

382386
func (b *backendMock) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) {
383-
//nolint: nilnil
387+
// nolint: nilnil
384388
return nil, nil
385389
}
386390

packaging/templates/package_scripts/control

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>

packaging/templates/package_scripts/control.arm64

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>
@@ -10,4 +10,3 @@ Architecture: arm64
1010
Multi-Arch: foreign
1111
Depends:
1212
Description: This is the bor package from Polygon Technology.
13-
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor-profile
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>
@@ -10,5 +10,3 @@ Architecture: amd64
1010
Multi-Arch: foreign
1111
Depends:
1212
Description: This is the bor package from Polygon Technology.
13-
14-

packaging/templates/package_scripts/control.profile.arm64

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor-profile
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>

packaging/templates/package_scripts/control.validator

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor-profile
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>

packaging/templates/package_scripts/control.validator.arm64

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Source: bor-profile
2-
Version: 1.1.0-beta3
2+
Version: 1.1.0
33
Section: develop
44
Priority: standard
55
Maintainer: Polygon <[email protected]>
@@ -10,4 +10,3 @@ Architecture: arm64
1010
Multi-Arch: foreign
1111
Depends:
1212
Description: This is the bor package from Polygon Technology.
13-

params/config.go

+23-29
Large diffs are not rendered by default.

params/config_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"testing"
2323
"time"
2424

25+
"gotest.tools/assert"
26+
2527
"github.com/ethereum/go-ethereum/common/math"
2628
)
2729

@@ -134,3 +136,45 @@ func TestConfigRules(t *testing.T) {
134136
t.Errorf("expected %v to be shanghai", 0)
135137
}
136138
}
139+
140+
func TestBorKeyValueConfigHelper(t *testing.T) {
141+
t.Parallel()
142+
143+
backupMultiplier := map[string]uint64{
144+
"0": 2,
145+
"25275000": 5,
146+
"29638656": 2,
147+
}
148+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 0), uint64(2))
149+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 1), uint64(2))
150+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000-1), uint64(2))
151+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000), uint64(5))
152+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 25275000+1), uint64(5))
153+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656-1), uint64(5))
154+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656), uint64(2))
155+
assert.Equal(t, borKeyValueConfigHelper(backupMultiplier, 29638656+1), uint64(2))
156+
157+
config := map[string]uint64{
158+
"0": 1,
159+
"90000000": 2,
160+
"100000000": 3,
161+
}
162+
assert.Equal(t, borKeyValueConfigHelper(config, 0), uint64(1))
163+
assert.Equal(t, borKeyValueConfigHelper(config, 1), uint64(1))
164+
assert.Equal(t, borKeyValueConfigHelper(config, 90000000-1), uint64(1))
165+
assert.Equal(t, borKeyValueConfigHelper(config, 90000000), uint64(2))
166+
assert.Equal(t, borKeyValueConfigHelper(config, 90000000+1), uint64(2))
167+
assert.Equal(t, borKeyValueConfigHelper(config, 100000000-1), uint64(2))
168+
assert.Equal(t, borKeyValueConfigHelper(config, 100000000), uint64(3))
169+
assert.Equal(t, borKeyValueConfigHelper(config, 100000000+1), uint64(3))
170+
171+
burntContract := map[string]string{
172+
"22640000": "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38",
173+
"41824608": "0x617b94CCCC2511808A3C9478ebb96f455CF167aA",
174+
}
175+
assert.Equal(t, borKeyValueConfigHelper(burntContract, 22640000), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
176+
assert.Equal(t, borKeyValueConfigHelper(burntContract, 22640000+1), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
177+
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608-1), "0x70bcA57F4579f58670aB2d18Ef16e02C17553C38")
178+
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA")
179+
assert.Equal(t, borKeyValueConfigHelper(burntContract, 41824608+1), "0x617b94CCCC2511808A3C9478ebb96f455CF167aA")
180+
}

params/version.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import (
2121
)
2222

2323
const (
24-
VersionMajor = 1 // Major version component of the current release
25-
VersionMinor = 1 // Minor version component of the current release
26-
VersionPatch = 0 // Patch version component of the current release
27-
VersionMeta = "beta3" // Version metadata to append to the version string
24+
VersionMajor = 1 // Major version component of the current release
25+
VersionMinor = 1 // Minor version component of the current release
26+
VersionPatch = 0 // Patch version component of the current release
27+
VersionMeta = "" // Version metadata to append to the version string
2828
)
2929

3030
var GitCommit string

tests/bor/helper.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,11 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
220220
ctx := context.Background()
221221

222222
// Finalize and seal the block
223-
block, _ := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts, []*types.Withdrawal{})
223+
block, err := _bor.FinalizeAndAssemble(ctx, chain, b.header, state, b.txs, nil, b.receipts, nil)
224+
225+
if err != nil {
226+
panic(fmt.Sprintf("error finalizing block: %v", err))
227+
}
224228

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

0 commit comments

Comments
 (0)