Skip to content

Commit

Permalink
Remove smart contracts path flags (#1254)
Browse files Browse the repository at this point in the history
* Remove smart contracts path flags

* Remove unused const
  • Loading branch information
Stefan-Ethernal authored Feb 28, 2023
1 parent 9a0c634 commit eccbae3
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 58 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/e2e-polybft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
uses: actions/setup-go@v3
with:
go-version: 1.18.x
- name: Compile core contracts
run: make compile-core-contracts
- name: Run tests
run: make test-e2e-polybft
- name: Archive test logs
Expand Down
8 changes: 0 additions & 8 deletions command/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/0xPolygon/polygon-edge/command/genesis/predeploy"
"github.com/0xPolygon/polygon-edge/command/helper"
"github.com/0xPolygon/polygon-edge/consensus/ibft"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/helper/common"
"github.com/0xPolygon/polygon-edge/validators"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -178,13 +177,6 @@ func setFlags(cmd *cobra.Command) {
"the predefined period which determines block creation frequency",
)

cmd.Flags().StringVar(
&params.smartContractsRootPath,
smartContractsRootPathFlag,
contracts.ContractsRootFolder,
"the smart contracts folder",
)

cmd.Flags().StringVar(
&params.bridgeJSONRPCAddr,
bridgeFlag,
Expand Down
13 changes: 6 additions & 7 deletions command/genesis/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ type genesisParams struct {
genesisConfig *chain.Chain

// PolyBFT
manifestPath string
smartContractsRootPath string
validatorSetSize int
sprintSize uint64
blockTime time.Duration
bridgeJSONRPCAddr string
epochReward uint64
manifestPath string
validatorSetSize int
sprintSize uint64
blockTime time.Duration
bridgeJSONRPCAddr string
epochReward uint64
}

func (p *genesisParams) validateFlags() error {
Expand Down
11 changes: 5 additions & 6 deletions command/genesis/polybft_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ import (
)

const (
smartContractsRootPathFlag = "contracts-path"
manifestPathFlag = "manifest"
validatorSetSizeFlag = "validator-set-size"
sprintSizeFlag = "sprint-size"
blockTimeFlag = "block-time"
bridgeFlag = "bridge-json-rpc"
manifestPathFlag = "manifest"
validatorSetSizeFlag = "validator-set-size"
sprintSizeFlag = "sprint-size"
blockTimeFlag = "block-time"
bridgeFlag = "bridge-json-rpc"

defaultManifestPath = "./manifest.json"
defaultEpochSize = uint64(10)
Expand Down
8 changes: 0 additions & 8 deletions command/rootchain/initcontracts/init_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/0xPolygon/polygon-edge/command/rootchain/helper"
"github.com/0xPolygon/polygon-edge/consensus/polybft"
"github.com/0xPolygon/polygon-edge/consensus/polybft/contractsapi"
"github.com/0xPolygon/polygon-edge/contracts"
"github.com/0xPolygon/polygon-edge/txrelayer"
"github.com/0xPolygon/polygon-edge/types"
)
Expand Down Expand Up @@ -71,13 +70,6 @@ func GetCommand() *cobra.Command {
}

func setFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(
&params.contractsPath,
contractsPathFlag,
contracts.ContractsRootFolder,
"Root directory path containing POS smart contracts",
)

cmd.Flags().StringVar(
&params.manifestPath,
manifestPathFlag,
Expand Down
12 changes: 3 additions & 9 deletions command/rootchain/initcontracts/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@ import (
)

const (
contractsPathFlag = "path"
manifestPathFlag = "manifest"
jsonRPCFlag = "json-rpc"
adminKeyFlag = "admin-key"
manifestPathFlag = "manifest"
jsonRPCFlag = "json-rpc"
adminKeyFlag = "admin-key"

defaultManifestPath = "./manifest.json"
)

type initContractsParams struct {
contractsPath string
manifestPath string
adminKey string
jsonRPCAddress string
}

func (ip *initContractsParams) validateFlags() error {
if _, err := os.Stat(ip.contractsPath); errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("provided smart contracts directory '%s' doesn't exist", ip.contractsPath)
}

if _, err := os.Stat(ip.manifestPath); errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("provided manifest path '%s' doesn't exist", ip.manifestPath)
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/polybft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ In order to do so, run `make compile-core-contracts`.
5. Deploy and initialize rootchain contracts - this command deploys rootchain smart contracts and initializes them. It also updates manifest configuration with rootchain contract addresses and rootchain default sender address.

```bash
polygon-edge rootchain init-contracts [--manifest ./manifest.json] [--contracts-path ./core-contracts/artifacts]
polygon-edge rootchain init-contracts [--manifest ./manifest.json]
[--json-rpc http://127.0.0.1:8545] [--admin-key <hex_encoded_private_key>]
```

6. Create chain configuration - this command creates chain configuration, which is needed to run a blockchain

```bash
polygon-edge genesis --consensus polybft --block-gas-limit 10000000 --epoch-size 10
[--bridge-json-rpc <rootchain_ip_address>] [--contracts-path ./core-contracts/artifacts] [--manifest ./manifest.json]
[--bridge-json-rpc <rootchain_ip_address>] [--manifest ./manifest.json]
```

7. Fund validators on rootchain - in order for validators to be able to send transactions to Ethereum, they need to be funded in order to be able to cover gas cost. **This command is for testing purposes only.**
Expand Down
6 changes: 0 additions & 6 deletions contracts/constants.go

This file was deleted.

1 change: 0 additions & 1 deletion e2e-polybft/framework/test-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (t *TestBridge) deployRootchainContracts(manifestPath string) error {
args := []string{
"rootchain",
"init-contracts",
"--path", t.clusterConfig.ContractsDir,
"--manifest", manifestPath,
}

Expand Down
9 changes: 0 additions & 9 deletions e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ const (
)

const (
// path to core contracts
defaultContractsPath = "./../core-contracts/artifacts/contracts/"

// prefix for validator directory
defaultValidatorPrefix = "test-chain-"
)
Expand Down Expand Up @@ -78,7 +75,6 @@ type TestClusterConfig struct {
LogsDir string
TmpDir string
BlockGasLimit uint64
ContractsDir string
ValidatorPrefix string
Binary string
ValidatorSetSize uint64
Expand Down Expand Up @@ -252,10 +248,6 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T
PremineValidators: command.DefaultPremineBalance,
}

if config.ContractsDir == "" {
config.ContractsDir = defaultContractsPath
}

if config.ValidatorPrefix == "" {
config.ValidatorPrefix = defaultValidatorPrefix
}
Expand Down Expand Up @@ -327,7 +319,6 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T
"--manifest", manifestPath,
"--consensus", "polybft",
"--dir", path.Join(config.TmpDir, "genesis.json"),
"--contracts-path", defaultContractsPath,
"--block-gas-limit", strconv.FormatUint(cluster.Config.BlockGasLimit, 10),
"--epoch-size", strconv.Itoa(cluster.Config.EpochSize),
"--epoch-reward", strconv.Itoa(cluster.Config.EpochReward),
Expand Down

0 comments on commit eccbae3

Please sign in to comment.