Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls committed Oct 1, 2024
2 parents b8901bc + 0b28bb5 commit af5c2b1
Show file tree
Hide file tree
Showing 21 changed files with 217 additions and 52 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
- name: Test
run: make test

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v4.4.0
with:
name: unitTest-coverage
path: cover.out
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
- name: test-integration
run: make test-integration

- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v4.4.0
with:
name: integrationTest-coverage
path: cover.out
Expand All @@ -174,7 +174,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v4.1.8
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3

Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.4.0
with:
name: logs_${{ github.run_id }}
path: |
Expand All @@ -277,7 +277,7 @@ jobs:
- name: Upload code and chain data
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.4.0
with:
name: code_${{ github.run_id }}
path: code.tar.gz
2 changes: 1 addition & 1 deletion .github/workflows/govuln.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-on-vuln: true

- name: Upload govulncheck report
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.0
with:
name: raw-report
path: raw-report.json
7 changes: 7 additions & 0 deletions accounts/abi/bind/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -94,6 +97,10 @@ func (mc *mockCaller) CallContract(ctx context.Context, call ethereum.CallMsg, b
return mc.callContractBytes, mc.callContractErr
}

func (mc *mockCaller) CallWithState(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, state *state.StateDB, overrides *ethapi.StateOverride, blockOverrides *ethapi.BlockOverrides) (hexutil.Bytes, error) {
return mc.CallContract(ctx, ethereum.CallMsg{}, nil)
}

type mockPendingCaller struct {
*mockCaller
pendingCodeAtBytes []byte
Expand Down
25 changes: 24 additions & 1 deletion builder/files/genesis-amoy.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions builder/files/genesis-mainnet-v1.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions consensus/bor/api/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import (
"context"

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/rpc"
)

//go:generate mockgen -destination=./caller_mock.go -package=api . Caller
type Caller interface {
Call(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *ethapi.StateOverride, blockOverrides *ethapi.BlockOverrides) (hexutil.Bytes, error)
CallWithState(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, state *state.StateDB, overrides *ethapi.StateOverride, blockOverrides *ethapi.BlockOverrides) (hexutil.Bytes, error)
}
16 changes: 16 additions & 0 deletions consensus/bor/api/caller_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions consensus/bor/contract/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ func (gc *GenesisContractsClient) LastStateId(state *state.StateDB, number uint6
toAddress := common.HexToAddress(gc.StateReceiverContract)
gas := (hexutil.Uint64)(uint64(math.MaxUint64 / 2))

// Do a call with state so that we can fetch the last state ID from a given (incoming)
// state instead of local(canonical) chain.
result, err := gc.ethAPI.Call(context.Background(), ethapi.TransactionArgs{
// BOR: Do a 'CallWithState' so that we can fetch the last state ID from a given (incoming)
// state instead of local(canonical) chain's state.
result, err := gc.ethAPI.CallWithState(context.Background(), ethapi.TransactionArgs{
Gas: &gas,
To: &toAddress,
Data: &msgData,
}, &rpc.BlockNumberOrHash{BlockNumber: &blockNr, BlockHash: &hash}, nil, nil)
}, &rpc.BlockNumberOrHash{BlockNumber: &blockNr, BlockHash: &hash}, state, nil, nil)
if err != nil {
return nil, err
}
Expand Down
9 changes: 6 additions & 3 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,13 @@ func MVRead[T any](s *StateDB, k blockstm.Key, defaultV T, readStorage func(s *S
return defaultV
}

// TODO: I assume we don't want to overwrite an existing read because this could - for example - change a storage
// read to map if the same value is read multiple times.
if _, ok := s.readMap[k]; !ok {
if prevRd, ok := s.readMap[k]; !ok {
s.readMap[k] = rd
} else {
if prevRd.Kind != rd.Kind || prevRd.V.TxnIndex != rd.V.TxnIndex || prevRd.V.Incarnation != rd.V.Incarnation {
s.dep = rd.V.TxnIndex
panic("Read conflict detected")
}
}

return
Expand Down
34 changes: 17 additions & 17 deletions core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ func TestMVHashMapOverwrite(t *testing.T) {
states := []*StateDB{s}

// Create copies of the original state for each transition
for i := 1; i <= 4; i++ {
for i := 1; i <= 5; i++ {
sCopy := s.Copy()
sCopy.txIndex = i
states = append(states, sCopy)
Expand Down Expand Up @@ -988,9 +988,9 @@ func TestMVHashMapOverwrite(t *testing.T) {
states[1].writeMap = nil
}

// Tx2 read should get Tx0's value
v = states[2].GetState(addr, key)
b = states[2].GetBalance(addr)
// Tx3 read should get Tx0's value
v = states[3].GetState(addr, key)
b = states[3].GetBalance(addr)

assert.Equal(t, val1, v)
assert.Equal(t, balance1, b)
Expand All @@ -1009,9 +1009,9 @@ func TestMVHashMapOverwrite(t *testing.T) {
states[0].writeMap = nil
}

// Tx2 read again should get default vals
v = states[2].GetState(addr, key)
b = states[2].GetBalance(addr)
// Tx4 read again should get default vals
v = states[4].GetState(addr, key)
b = states[4].GetBalance(addr)

assert.Equal(t, common.Hash{}, v)
assert.Equal(t, uint256.NewInt(0), b)
Expand All @@ -1027,7 +1027,7 @@ func TestMVHashMapWriteNoConflict(t *testing.T) {
states := []*StateDB{s}

// Create copies of the original state for each transition
for i := 1; i <= 4; i++ {
for i := 1; i <= 6; i++ {
sCopy := s.Copy()
sCopy.txIndex = i
states = append(states, sCopy)
Expand Down Expand Up @@ -1078,17 +1078,17 @@ func TestMVHashMapWriteNoConflict(t *testing.T) {
states[2].writeMap = nil
}

assert.Equal(t, val1, states[3].GetState(addr, key1))
assert.Equal(t, balance1, states[3].GetBalance(addr))
assert.Equal(t, common.Hash{}, states[3].GetState(addr, key2))
assert.Equal(t, val1, states[4].GetState(addr, key1))
assert.Equal(t, balance1, states[4].GetBalance(addr))
assert.Equal(t, common.Hash{}, states[4].GetState(addr, key2))

// Tx1 revert
states[1].RevertToSnapshot(tx1Snapshot)
states[1].FlushMVWriteSet()

assert.Equal(t, common.Hash{}, states[3].GetState(addr, key1))
assert.Equal(t, common.Hash{}, states[3].GetState(addr, key2))
assert.Equal(t, uint256.NewInt(0), states[3].GetBalance(addr))
assert.Equal(t, common.Hash{}, states[5].GetState(addr, key1))
assert.Equal(t, common.Hash{}, states[5].GetState(addr, key2))
assert.Equal(t, uint256.NewInt(0), states[5].GetBalance(addr))

// Tx1 delete
for _, v := range states[1].writeMap {
Expand All @@ -1097,9 +1097,9 @@ func TestMVHashMapWriteNoConflict(t *testing.T) {
states[1].writeMap = nil
}

assert.Equal(t, common.Hash{}, states[3].GetState(addr, key1))
assert.Equal(t, common.Hash{}, states[3].GetState(addr, key2))
assert.Equal(t, uint256.NewInt(0), states[3].GetBalance(addr))
assert.Equal(t, common.Hash{}, states[6].GetState(addr, key1))
assert.Equal(t, common.Hash{}, states[6].GetState(addr, key2))
assert.Equal(t, uint256.NewInt(0), states[6].GetBalance(addr))
}

func TestApplyMVWriteSet(t *testing.T) {
Expand Down
32 changes: 29 additions & 3 deletions internal/cli/server/chains/amoy.go

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions internal/cli/server/chains/mainnet.go

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1360,11 +1360,24 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
// Note, this function doesn't make and changes in the state/blockchain and is
// useful to execute and retrieve values.
func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error) {
return api.CallWithState(ctx, args, blockNrOrHash, nil, overrides, blockOverrides)
}

// CallWithState executes the given transaction on the given state for
// the given block number. Note that as it does an EVM call, fields in
// the underlying state will change. Make sure to handle it outside of
// this function (ideally by sending a copy of state).
//
// Additionally, the caller can specify a batch of contract for fields overriding.
//
// Note, this function doesn't make and changes in the state/blockchain and is
// useful to execute and retrieve values.
func (api *BlockChainAPI) CallWithState(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, state *state.StateDB, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error) {
if blockNrOrHash == nil {
latest := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
blockNrOrHash = &latest
}
result, err := DoCall(ctx, api.b, args, *blockNrOrHash, nil, overrides, blockOverrides, api.b.RPCEVMTimeout(), api.b.RPCGasCap())
result, err := DoCall(ctx, api.b, args, *blockNrOrHash, state, overrides, blockOverrides, api.b.RPCEVMTimeout(), api.b.RPCGasCap())
if err != nil {
return nil, err
}
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.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion 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.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
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.3.7
Version: 1.4.1
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.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
Loading

0 comments on commit af5c2b1

Please sign in to comment.