Skip to content

Commit

Permalink
votingStation txn withOpts
Browse files Browse the repository at this point in the history
  • Loading branch information
akshar committed Nov 6, 2023
1 parent 76c5c21 commit 086dd72
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ build:
-X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime=$(TIME)'" \
main.go

.PHONY: build-amd
build-amd:
$(eval LATEST_VERSION = $(shell git describe --tags --abbrev=0))
$(eval COMMIT_HASH = $(shell git rev-parse HEAD))
$(eval BRANCH = $(shell git rev-parse --abbrev-ref HEAD | tr -d '\040\011\012\015\n'))
$(eval TIME = $(shell date))
GOOS=linux GOARCH=amd64 go build -o main -ldflags="\
-X 'github.com/0xPolygon/polygon-edge/versioning.Version=$(LATEST_VERSION)' \
-X 'github.com/0xPolygon/polygon-edge/versioning.Commit=$(COMMIT_HASH)'\
-X 'github.com/0xPolygon/polygon-edge/versioning.Branch=$(BRANCH)'\
-X 'github.com/0xPolygon/polygon-edge/versioning.BuildTime=$(TIME)'" \
main.go

.PHONY: lint
lint:
golangci-lint run --config .golangci.yml
Expand Down
19 changes: 18 additions & 1 deletion command/ibft/propose/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const (
voteRemoveSCFunction = "function voteDrop(address oldValidator)"
)

const (
txGasPriceWei = 1000000000
txGasLimitWei = 1000000
)

type proposeParams struct {
addressRaw string
rawBLSPublicKey string
Expand Down Expand Up @@ -207,6 +212,13 @@ func (p *proposeParams) ibftSetVotingStationValidators(grpcAddress string, jsonr
functionArgs...,
)

txn.WithOpts(
&contract.TxnOpts{
GasPrice: (20 * txGasPriceWei),
GasLimit: txGasLimitWei,
},
)

if txnErr != nil {
fmt.Println(fmt.Errorf("failed to initiate voting-station txn %w", txnErr))
return txnErr
Expand All @@ -219,13 +231,18 @@ func (p *proposeParams) ibftSetVotingStationValidators(grpcAddress string, jsonr
return executeErr
}

_, mineError := txn.Wait()
receipt, mineError := txn.Wait()

if mineError != nil {
fmt.Println(fmt.Errorf("failed to mine voting-station txn %w", mineError))
return mineError
}

if receipt.Status != 1 {
fmt.Println("txn failed")
return fmt.Errorf("txn failed")
}

return nil

}
Expand Down

0 comments on commit 086dd72

Please sign in to comment.