Merge pull request #1341 from cffls/develop

Backporting master to develop
This commit is contained in:
Jerry 2024-10-03 10:09:46 -07:00 committed by GitHub
commit 3949415fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 217 additions and 54 deletions

View file

@ -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
@ -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
@ -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
@ -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: |
@ -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

View file

@ -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

View file

@ -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"
)
@ -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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -2019,7 +2019,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
}
}
log.Info("flags", "genesis", cfg.Genesis)
// Set any dangling config values
if ctx.String(CryptoKZGFlag.Name) != "gokzg" && ctx.String(CryptoKZGFlag.Name) != "ckzg" {
Fatalf("--%s flag must be 'gokzg' or 'ckzg'", CryptoKZGFlag.Name)
@ -2095,7 +2094,6 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
}})
// avoiding constructor changed by introducing new method to set genesis
log.Info("filterAPI", "genesis", ethcfg.Genesis)
filterAPI.SetChainConfig(ethcfg.Genesis.Config)
return filterSystem

View file

@ -4,6 +4,7 @@ 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"
)
@ -11,4 +12,5 @@ import (
//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)
}

View file

@ -9,6 +9,7 @@ import (
reflect "reflect"
hexutil "github.com/ethereum/go-ethereum/common/hexutil"
state "github.com/ethereum/go-ethereum/core/state"
ethapi "github.com/ethereum/go-ethereum/internal/ethapi"
rpc "github.com/ethereum/go-ethereum/rpc"
gomock "github.com/golang/mock/gomock"
@ -51,3 +52,18 @@ func (mr *MockCallerMockRecorder) Call(arg0, arg1, arg2, arg3, arg4 interface{})
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockCaller)(nil).Call), arg0, arg1, arg2, arg3, arg4)
}
// CallWithState mocks base method.
func (m *MockCaller) CallWithState(arg0 context.Context, arg1 ethapi.TransactionArgs, arg2 *rpc.BlockNumberOrHash, arg3 *state.StateDB, arg4 *ethapi.StateOverride, arg5 *ethapi.BlockOverrides) (hexutil.Bytes, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CallWithState", arg0, arg1, arg2, arg3, arg4, arg5)
ret0, _ := ret[0].(hexutil.Bytes)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// CallWithState indicates an expected call of CallWithState.
func (mr *MockCallerMockRecorder) CallWithState(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CallWithState", reflect.TypeOf((*MockCaller)(nil).CallWithState), arg0, arg1, arg2, arg3, arg4, arg5)
}

View file

@ -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
}

View file

@ -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

View file

@ -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)
@ -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)
@ -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)
@ -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)
@ -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 {
@ -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) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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
}

View file

@ -1,5 +1,5 @@
Source: bor
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile
Version: 1.3.7
Version: 1.4.1
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>

File diff suppressed because one or more lines are too long

View file

@ -22,8 +22,8 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 7 // Patch version component of the current release
VersionMinor = 4 // Minor version component of the current release
VersionPatch = 1 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)