Skip to content

Commit 69c4199

Browse files
committed
Merge branch 'master' into go-1.15.5-recompile
2 parents fb8b49f + 7b72638 commit 69c4199

File tree

110 files changed

+14024
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+14024
-1422
lines changed

cmd/geth/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
166166
}
167167

168168
if cfg.Node.IsPermissionEnabled() {
169-
utils.RegisterPermissionService(stack)
169+
utils.RegisterPermissionService(stack, ctx.Bool(utils.RaftDNSEnabledFlag.Name))
170170
}
171171

172172
if ctx.GlobalBool(utils.RaftModeFlag.Name) {

cmd/geth/main.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,16 @@ func startNode(ctx *cli.Context, stack *node.Node) {
462462
// Quorum
463463
//
464464
// checking if permissions is enabled and staring the permissions service
465-
if stack.IsPermissionEnabled() {
466-
var permissionService *permission.PermissionCtrl
467-
if err := stack.Service(&permissionService); err != nil {
468-
utils.Fatalf("Permission service not runnning: %v", err)
469-
}
470-
if err := permissionService.AfterStart(); err != nil {
471-
utils.Fatalf("Permission service post construct failure: %v", err)
465+
if stack.Config().EnableNodePermission {
466+
stack.Server().SetIsNodePermissioned(permission.IsNodePermissioned)
467+
if stack.IsPermissionEnabled() {
468+
var permissionService *permission.PermissionCtrl
469+
if err := stack.Service(&permissionService); err != nil {
470+
utils.Fatalf("Permission service not runnning: %v", err)
471+
}
472+
if err := permissionService.AfterStart(); err != nil {
473+
utils.Fatalf("Permission service post construct failure: %v", err)
474+
}
472475
}
473476
}
474477

cmd/utils/flags.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ import (
6868
"github.com/ethereum/go-ethereum/p2p/netutil"
6969
"github.com/ethereum/go-ethereum/params"
7070
"github.com/ethereum/go-ethereum/permission"
71+
"github.com/ethereum/go-ethereum/permission/core/types"
7172
"github.com/ethereum/go-ethereum/plugin"
7273
"github.com/ethereum/go-ethereum/private"
7374
"github.com/ethereum/go-ethereum/raft"
@@ -1833,14 +1834,14 @@ func RegisterPluginService(stack *node.Node, cfg *node.Config, skipVerify bool,
18331834
}
18341835

18351836
// Configure smart-contract-based permissioning service
1836-
func RegisterPermissionService(stack *node.Node) {
1837+
func RegisterPermissionService(stack *node.Node, useDns bool) {
18371838
if err := stack.Register(func(sctx *node.ServiceContext) (node.Service, error) {
1838-
permissionConfig, err := permission.ParsePermissionConfig(stack.DataDir())
1839+
permissionConfig, err := types.ParsePermissionConfig(stack.DataDir())
18391840
if err != nil {
18401841
return nil, fmt.Errorf("loading of %s failed due to %v", params.PERMISSION_MODEL_CONFIG, err)
18411842
}
18421843
// start the permissions management service
1843-
pc, err := permission.NewQuorumPermissionCtrl(stack, &permissionConfig)
1844+
pc, err := permission.NewQuorumPermissionCtrl(stack, &permissionConfig, useDns)
18441845
if err != nil {
18451846
return nil, fmt.Errorf("failed to load the permission contracts as given in %s due to %v", params.PERMISSION_MODEL_CONFIG, err)
18461847
}
@@ -1898,6 +1899,7 @@ func RegisterRaftService(stack *node.Node, ctx *cli.Context, nodeCfg *node.Confi
18981899
}); err != nil {
18991900
Fatalf("Failed to register the Raft service: %v", err)
19001901
}
1902+
log.Info("raft service registered")
19011903
}
19021904

19031905
func RegisterExtensionService(stack *node.Node, ethChan chan *eth.Ethereum) {

core/forkid/forkid.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ func gatherForks(config *params.ChainConfig) []uint64 {
224224
if field.Type != reflect.TypeOf(new(big.Int)) {
225225
continue
226226
}
227+
228+
// ignoring QIP714Block from fork check
229+
if field.Name == "QIP714Block" {
230+
continue
231+
}
227232
// Extract the fork rule block number and aggregate it
228233
rule := conf.Field(i).Interface().(*big.Int)
229234
if rule != nil {

core/state_processor.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/ethereum/go-ethereum/core/vm"
2626
"github.com/ethereum/go-ethereum/crypto"
2727
"github.com/ethereum/go-ethereum/params"
28+
"github.com/ethereum/go-ethereum/permission/core"
2829
)
2930

3031
// StateProcessor is a basic Processor, which takes care of transitioning
@@ -114,6 +115,13 @@ func ApplyTransaction(config *params.ChainConfig, bc *BlockChain, author *common
114115
privateStateDbToUse := PrivateStateDBForTxn(config.IsQuorum, tx.IsPrivate(), statedb, privateState)
115116
// /Quorum
116117

118+
// Quorum - check for account permissions to execute the transaction
119+
if core.IsV2Permission() {
120+
if err := core.CheckAccountPermission(tx.From(), tx.To(), tx.Value(), tx.Data(), tx.Gas(), tx.GasPrice()); err != nil {
121+
return nil, nil, err
122+
}
123+
}
124+
117125
if config.IsQuorum && tx.GasPrice() != nil && tx.GasPrice().Cmp(common.Big0) > 0 {
118126
return nil, nil, ErrInvalidGasPrice
119127
}

core/tx_pool.go

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/ethereum/go-ethereum/log"
3434
"github.com/ethereum/go-ethereum/metrics"
3535
"github.com/ethereum/go-ethereum/params"
36+
pcore "github.com/ethereum/go-ethereum/permission/core"
3637
)
3738

3839
const (
@@ -153,7 +154,6 @@ type TxPoolConfig struct {
153154
// Quorum
154155
TransactionSizeLimit uint64 // Maximum size allowed for valid transaction (in KB)
155156
MaxCodeSize uint64 // Maximum size allowed of contract code that can be deployed (in KB)
156-
157157
}
158158

159159
// DefaultTxPoolConfig contains the default configurations for the transaction
@@ -560,8 +560,8 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
560560
if tx.IsPrivate() && (len(tx.Data()) == 0 || tx.Value().Sign() != 0) {
561561
return ErrEtherValueUnsupported
562562
}
563-
// Check if the sender account is authorized to perform the transaction
564-
if err := checkAccount(from, tx.To()); err != nil {
563+
// Quorum - check if the sender account is authorized to perform the transaction
564+
if err := pcore.CheckAccountPermission(tx.From(), tx.To(), tx.Value(), tx.Data(), tx.Gas(), tx.GasPrice()); err != nil {
565565
return err
566566
}
567567
} else {
@@ -1595,26 +1595,6 @@ func (t *txLookup) Remove(hash common.Hash) {
15951595
delete(t.all, hash)
15961596
}
15971597

1598-
// checks if the account is has the necessary access for the transaction
1599-
func checkAccount(fromAcct common.Address, toAcct *common.Address) error {
1600-
access := types.GetAcctAccess(fromAcct)
1601-
1602-
switch access {
1603-
case types.ReadOnly:
1604-
return errors.New("read only account. cannot transact")
1605-
1606-
case types.Transact:
1607-
if toAcct == nil {
1608-
return errors.New("account does not have contract create permissions")
1609-
}
1610-
1611-
case types.FullAccess, types.ContractDeploy:
1612-
return nil
1613-
1614-
}
1615-
return nil
1616-
}
1617-
16181598
// helper function to return chainHeadChannel size
16191599
func GetChainHeadChannleSize() int {
16201600
return chainHeadChanSize

core/types/transaction.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ package types
1919
import (
2020
"container/heap"
2121
"errors"
22+
"fmt"
2223
"io"
2324
"math/big"
2425
"sync/atomic"
2526

26-
fmt "fmt"
27-
2827
"github.com/ethereum/go-ethereum/common"
2928
"github.com/ethereum/go-ethereum/common/hexutil"
3029
"github.com/ethereum/go-ethereum/crypto"

eth/api_backend.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/ethereum/go-ethereum/ethdb"
3838
"github.com/ethereum/go-ethereum/event"
3939
"github.com/ethereum/go-ethereum/params"
40+
pcore "github.com/ethereum/go-ethereum/permission/core"
4041
"github.com/ethereum/go-ethereum/rpc"
4142
)
4243

@@ -261,7 +262,7 @@ func (b *EthAPIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscri
261262
func (b *EthAPIBackend) SendTx(ctx context.Context, signedTx *types.Transaction) error {
262263
// validation for node need to happen here and cannot be done as a part of
263264
// validateTx in tx_pool.go as tx_pool validation will happen in every node
264-
if b.hexNodeId != "" && !types.ValidateNodeForTxn(b.hexNodeId, signedTx.From()) {
265+
if b.hexNodeId != "" && !pcore.ValidateNodeForTxn(b.hexNodeId, signedTx.From()) {
265266
return errors.New("cannot send transaction from this node")
266267
}
267268
return b.eth.txPool.AddLocal(signedTx)

eth/downloader/downloader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/ethereum/go-ethereum/log"
3535
"github.com/ethereum/go-ethereum/metrics"
3636
"github.com/ethereum/go-ethereum/params"
37+
"github.com/ethereum/go-ethereum/permission/core"
3738
"github.com/ethereum/go-ethereum/trie"
3839
)
3940

@@ -362,7 +363,7 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td *big.Int, mode
362363

363364
// Quorum
364365
// changes for permissions. added set sync status to indicate permissions that node sync has started
365-
types.SetSyncStatus()
366+
core.SetSyncStatus()
366367

367368
defer atomic.StoreInt32(&d.synchronising, 0)
368369

eth/sync.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/ethereum/go-ethereum/eth/downloader"
2727
"github.com/ethereum/go-ethereum/log"
2828
"github.com/ethereum/go-ethereum/p2p/enode"
29+
"github.com/ethereum/go-ethereum/permission/core"
2930
)
3031

3132
const (
@@ -179,7 +180,7 @@ func (pm *ProtocolManager) synchronise(peer *peer) {
179180
// Quorum
180181
// added for permissions changes to indicate node sync up has started
181182
// if peer's TD is smaller than ours, no sync will happen
182-
types.SetSyncStatus()
183+
core.SetSyncStatus()
183184
return
184185
}
185186
// Otherwise try to sync with the downloader

0 commit comments

Comments
 (0)