mirror of https://github.com/poanetwork/quorum.git
permission: let nonce to be decided by the binding
This commit is contained in:
parent
37cbb620ec
commit
23be20b1b7
|
@ -668,12 +668,12 @@ func (p *PermissionCtrl) populateInitPermissions() error {
|
||||||
|
|
||||||
// initialize the permissions model and populate initial values
|
// initialize the permissions model and populate initial values
|
||||||
func (p *PermissionCtrl) bootupNetwork(permInterfSession *pbind.PermInterfaceSession) error {
|
func (p *PermissionCtrl) bootupNetwork(permInterfSession *pbind.PermInterfaceSession) error {
|
||||||
permInterfSession.TransactOpts.Nonce = new(big.Int).SetUint64(p.eth.TxPool().Nonce(permInterfSession.TransactOpts.From))
|
// permInterfSession.TransactOpts.Nonce = new(big.Int).SetUint64(p.eth.TxPool().State().GetNonce(permInterfSession.TransactOpts.From))
|
||||||
if _, err := permInterfSession.SetPolicy(p.permConfig.NwAdminOrg, p.permConfig.NwAdminRole, p.permConfig.OrgAdminRole); err != nil {
|
if _, err := permInterfSession.SetPolicy(p.permConfig.NwAdminOrg, p.permConfig.NwAdminRole, p.permConfig.OrgAdminRole); err != nil {
|
||||||
log.Error("bootupNetwork SetPolicy failed", "err", err)
|
log.Error("bootupNetwork SetPolicy failed", "err", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
permInterfSession.TransactOpts.Nonce = new(big.Int).SetUint64(p.eth.TxPool().Nonce(permInterfSession.TransactOpts.From))
|
// permInterfSession.TransactOpts.Nonce = new(big.Int).SetUint64(p.eth.TxPool().State().GetNonce(permInterfSession.TransactOpts.From))
|
||||||
if _, err := permInterfSession.Init(&p.permConfig.SubOrgBreadth, &p.permConfig.SubOrgDepth); err != nil {
|
if _, err := permInterfSession.Init(&p.permConfig.SubOrgBreadth, &p.permConfig.SubOrgDepth); err != nil {
|
||||||
log.Error("bootupNetwork init failed", "err", err)
|
log.Error("bootupNetwork init failed", "err", err)
|
||||||
return err
|
return err
|
||||||
|
@ -812,8 +812,8 @@ func (p *PermissionCtrl) populateStaticNodesToContract(permissionsSession *pbind
|
||||||
// set of accounts access to full access
|
// set of accounts access to full access
|
||||||
func (p *PermissionCtrl) populateInitAccountAccess(permissionsSession *pbind.PermInterfaceSession) error {
|
func (p *PermissionCtrl) populateInitAccountAccess(permissionsSession *pbind.PermInterfaceSession) error {
|
||||||
for _, a := range p.permConfig.Accounts {
|
for _, a := range p.permConfig.Accounts {
|
||||||
nonce := p.eth.TxPool().Nonce(permissionsSession.TransactOpts.From)
|
//nonce := p.eth.TxPool().Nonce(permissionsSession.TransactOpts.From)
|
||||||
permissionsSession.TransactOpts.Nonce = new(big.Int).SetUint64(nonce)
|
//permissionsSession.TransactOpts.Nonce = new(big.Int).SetUint64(nonce)
|
||||||
_, er := permissionsSession.AddAdminAccount(a)
|
_, er := permissionsSession.AddAdminAccount(a)
|
||||||
if er != nil {
|
if er != nil {
|
||||||
log.Warn("Error adding permission initial account list", "err", er, "account", a)
|
log.Warn("Error adding permission initial account list", "err", er, "account", a)
|
||||||
|
@ -826,8 +826,8 @@ func (p *PermissionCtrl) populateInitAccountAccess(permissionsSession *pbind.Per
|
||||||
|
|
||||||
// updates network boot status to true
|
// updates network boot status to true
|
||||||
func (p *PermissionCtrl) updateNetworkStatus(permissionsSession *pbind.PermInterfaceSession) error {
|
func (p *PermissionCtrl) updateNetworkStatus(permissionsSession *pbind.PermInterfaceSession) error {
|
||||||
nonce := p.eth.TxPool().Nonce(permissionsSession.TransactOpts.From)
|
//nonce := p.eth.TxPool().Nonce(permissionsSession.TransactOpts.From)
|
||||||
permissionsSession.TransactOpts.Nonce = new(big.Int).SetUint64(nonce)
|
//permissionsSession.TransactOpts.Nonce = new(big.Int).SetUint64(nonce)
|
||||||
_, err := permissionsSession.UpdateNetworkBootStatus()
|
_, err := permissionsSession.UpdateNetworkBootStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Failed to udpate network boot status ", "err", err)
|
log.Warn("Failed to udpate network boot status ", "err", err)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package permission
|
package permission
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -23,8 +24,10 @@ import (
|
||||||
pbind "github.com/ethereum/go-ethereum/permission/bind"
|
pbind "github.com/ethereum/go-ethereum/permission/bind"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPermissionCtrl_InitializeService(t *testing.T) {
|
func TestPermissionCtrl_AfterStart(t *testing.T) {
|
||||||
guardianKey, _ := crypto.GenerateKey()
|
guardianKey, _ := crypto.GenerateKey()
|
||||||
|
nodeKey, _ := crypto.GenerateKey()
|
||||||
|
|
||||||
guardianAddress := crypto.PubkeyToAddress(guardianKey.PublicKey)
|
guardianAddress := crypto.PubkeyToAddress(guardianKey.PublicKey)
|
||||||
|
|
||||||
guardianTransactor := bind.NewKeyedTransactor(guardianKey)
|
guardianTransactor := bind.NewKeyedTransactor(guardianKey)
|
||||||
|
@ -38,7 +41,7 @@ func TestPermissionCtrl_InitializeService(t *testing.T) {
|
||||||
DataDir: "",
|
DataDir: "",
|
||||||
UseLightweightKDF: true,
|
UseLightweightKDF: true,
|
||||||
P2P: p2p.Config{
|
P2P: p2p.Config{
|
||||||
PrivateKey: guardianKey,
|
PrivateKey: nodeKey,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -126,7 +129,7 @@ func TestPermissionCtrl_InitializeService(t *testing.T) {
|
||||||
go func() {
|
go func() {
|
||||||
testObject.errorChan <- nil
|
testObject.errorChan <- nil
|
||||||
}()
|
}()
|
||||||
|
fmt.Println("after start")
|
||||||
err = testObject.AfterStart()
|
err = testObject.AfterStart()
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
Loading…
Reference in New Issue