-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ci/workflows_update_pr
- Loading branch information
Showing
18 changed files
with
331 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ on: | |
tags: | ||
- v* | ||
branches: | ||
- main | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,10 @@ on: | |
tags: | ||
- v* | ||
branches: | ||
- main | ||
- "main" | ||
pull_request: | ||
jobs: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
|
@@ -19,7 +19,7 @@ jobs: | |
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.20.5 | ||
go-version: 1.22.1 | ||
- run: git config --global url.https://[email protected]/.insteadOf https://github.com/ | ||
|
||
- name: Build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package block | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
|
||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/evmos/evmos/v12/crypto/hd" | ||
"github.com/ignite/cli/ignite/pkg/cosmosaccount" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
) | ||
|
||
func (m *Manager) RunInitChain(ctx context.Context) error { | ||
|
||
// We pass an initial val set which is actually the consensus and operator addresses of the proposer. | ||
// This is a hack to make sure the chain can get both addresses without us needing to change comet signatures: | ||
// The RDK will save a sequencer, and delete the extra validator after initChain, so we also delete it here | ||
// to keep the state in sync. | ||
|
||
//get the proposer's consensus pubkey | ||
proposer := m.settlementClient.GetProposer() | ||
tmPubKey, err := cryptocodec.ToTmPubKeyInterface(proposer.PublicKey) | ||
if err != nil { | ||
return err | ||
} | ||
consensusPubkey := tmtypes.NewValidator(tmPubKey, 1) | ||
|
||
//get the operator's pubkey | ||
pubkey, err := getOperatorPubkey(m.conf.OperatorKeyringHomeDir, m.conf.OperatorKeyringBackend, m.conf.OperatorAccountName) | ||
if err != nil { | ||
return err | ||
} | ||
tmPubKey, err = cryptocodec.ToTmPubKeyInterface(pubkey) | ||
if err != nil { | ||
return err | ||
} | ||
operatorPubkey := tmtypes.NewValidator(tmPubKey, 1) | ||
|
||
//call initChain with both addresses | ||
res, err := m.executor.InitChain(m.genesis, []*tmtypes.Validator{consensusPubkey, operatorPubkey}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
//update the state with only the consensus pubkey | ||
m.executor.UpdateStateAfterInitChain(&m.lastState, res, []*tmtypes.Validator{consensusPubkey}) | ||
if _, err := m.store.UpdateState(m.lastState, nil); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func getOperatorPubkey(keyDir, keyringBackend, accountName string) (cryptotypes.PubKey, error) { | ||
// open keyring | ||
c, err := cosmosaccount.New( | ||
cosmosaccount.WithKeyringBackend(cosmosaccount.KeyringBackend(keyringBackend)), | ||
cosmosaccount.WithHome(keyDir), | ||
) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
interfaceRegistry := codectypes.NewInterfaceRegistry() | ||
cryptocodec.RegisterInterfaces(interfaceRegistry) | ||
cdc := codec.NewProtoCodec(interfaceRegistry) | ||
|
||
customKeyring, err := keyring.New("operatorAddr", keyringBackend, keyDir, os.Stdin, cdc, hd.EthSecp256k1Option()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
c.Keyring = customKeyring | ||
|
||
// If the keyring is in memory, ensure the default account exists to be used in tests | ||
if keyringBackend == "memory" { | ||
err := c.EnsureDefaultAccount() | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
// Get account from the keyring | ||
account, err := c.GetByName(accountName) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
pubkey, err := account.Record.GetPubKey() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return pubkey, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.