Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a case where priorityFee > maxFee in the task loop #655

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rocketpool/node/auto-init-voting-power.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (t *autoInitVotingPower) submitInitializeVotingPower() error {
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Initialize the Voting Power
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/node/defend-pdao-props.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (t *defendPdaoProps) defendProposal(prop defendableProposal) error {
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Respond to the challenge
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/node/distribute-minipools.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (t *distributeMinipools) distributeMinipool(mpd *rpstate.NativeMinipoolDeta
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Distribute minipool
Expand Down
18 changes: 18 additions & 0 deletions rocketpool/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,24 @@ func updateNetworkState(m *state.NetworkStateManager, log *log.ColorLogger, node
return state, totalEffectiveStake, nil
}

// Checks if the user-inputted priorityFee is greater than the oracle based maxFee
// If so, return the min(priorityFee, 25% of the oracle based maxFee)
func GetPriorityFee(priorityFee *big.Int, maxFee *big.Int) *big.Int {
// Check if priorityFee is less than maxFee
if priorityFee.Cmp(maxFee) < 0 {
return priorityFee
}

quarterMaxFee := new(big.Int).Div(maxFee, big.NewInt(4))

// Gets the min(priorityFee, 25% of the oracle based maxFee)
if priorityFee.Cmp(quarterMaxFee) < 0 {
return priorityFee
} else {
return quarterMaxFee
}
Comment on lines +410 to +412
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else {
return quarterMaxFee
}
return quarterMaxFee

}

// Check if Houston has been deployed yet
func printHoustonMessage(log *log.ColorLogger) {
log.Println(`
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/node/promote-minipools.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (t *promoteMinipools) promoteMinipool(mpd *rpstate.NativeMinipoolDetails, c
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Promote minipool
Expand Down
4 changes: 2 additions & 2 deletions rocketpool/node/reduce-bonds.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func (t *reduceBonds) forceFeeDistribution() (bool, error) {
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Distribute
Expand Down Expand Up @@ -400,7 +400,7 @@ func (t *reduceBonds) reduceBond(mpd *rpstate.NativeMinipoolDetails, windowStart
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Reduce bond
Expand Down
2 changes: 1 addition & 1 deletion rocketpool/node/stake-prelaunch-minipools.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (t *stakePrelaunchMinipools) stakeMinipool(mpd *rpstate.NativeMinipoolDetai
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Stake minipool
Expand Down
4 changes: 2 additions & 2 deletions rocketpool/node/verify-pdao-props.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (t *verifyPdaoProps) submitChallenge(challenge challenge) error {
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Respond to the challenge
Expand Down Expand Up @@ -439,7 +439,7 @@ func (t *verifyPdaoProps) submitDefeat(defeat defeat) error {
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

// Respond to the challenge
Expand Down
3 changes: 2 additions & 1 deletion rocketpool/watchtower/process-penalties.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/urfave/cli"
"gopkg.in/yaml.v2"

fee "github.com/rocket-pool/smartnode/rocketpool/node"
"github.com/rocket-pool/smartnode/shared/services"
"github.com/rocket-pool/smartnode/shared/services/wallet"
"github.com/rocket-pool/smartnode/shared/utils/api"
Expand Down Expand Up @@ -516,7 +517,7 @@ func (t *processPenalties) submitPenalty(minipoolAddress common.Address, block *
}

opts.GasFeeCap = maxFee
opts.GasTipCap = t.maxPriorityFee
opts.GasTipCap = fee.GetPriorityFee(t.maxPriorityFee, maxFee)
opts.GasLimit = gas.Uint64()

hash, err := network.SubmitPenalty(t.rp, minipoolAddress, slotBig, opts)
Expand Down
Loading