Skip to content

Commit

Permalink
Merge branch 'p-chain_update_fee_calculator' into p-chain_update_wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
abi87 committed Jul 15, 2024
2 parents de92116 + e43d4ff commit 2c30347
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 47 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Trigger Antithesis Test Runs
name: Trigger Antithesis Avalanchego Setup

on:
# TODO(marun) Add a schedule to execute regularly
Expand All @@ -10,8 +10,7 @@ on:
required: true
type: string
recipients:
description: 'Email recipients to send the test report to'
default: ${{ secrets.ANTITHESIS_RECIPIENTS }}
description: 'Comma-seperated email addresses to send the test report to'
required: true
type: string
image_tag:
Expand All @@ -37,19 +36,3 @@ jobs:
email_recipients: ${{ github.event.inputs.recipients || secrets.ANTITHESIS_RECIPIENTS }}
additional_parameters: |-
custom.duration=${{ github.event.inputs.duration || '0.5' }}
antithesis_xsvm:
name: Run Antithesis XSVM Test Setup
runs-on: ubuntu-latest
steps:
- uses: antithesishq/antithesis-trigger-action@v0.5
with:
notebook_name: avalanche
tenant: avalanche
username: ${{ secrets.ANTITHESIS_USERNAME }}
password: ${{ secrets.ANTITHESIS_PASSWORD }}
github_token: ${{ secrets.ANTITHESIS_GH_PAT }}
config_image: antithesis-xsvm-config@${{ github.event.inputs.image_tag || 'latest' }}
images: antithesis-xsvm-workload@${{ github.event.inputs.image_tag || 'latest' }};antithesis-xsvm-node@${{ github.event.inputs.image_tag || 'latest' }}
email_recipients: ${{ github.event.inputs.recipients || secrets.ANTITHESIS_RECIPIENTS }}
additional_parameters: |-
custom.duration=${{ github.event.inputs.duration || '0.5' }}
38 changes: 38 additions & 0 deletions .github/workflows/trigger-antithesis-xsvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Trigger Antithesis XSVM Setup

on:
# TODO(marun) Add a schedule to execute regularly
workflow_dispatch:
inputs:
duration:
description: 'The duration to run the test for'
default: '0.5'
required: true
type: string
recipients:
description: 'Comma-seperated email addresses to send the test report to'
required: true
type: string
image_tag:
description: 'The image tag to target'
default: latest
required: true
type: string

jobs:
antithesis_xsvm:
name: Run Antithesis XSVM Test Setup
runs-on: ubuntu-latest
steps:
- uses: antithesishq/antithesis-trigger-action@v0.5
with:
notebook_name: avalanche
tenant: avalanche
username: ${{ secrets.ANTITHESIS_USERNAME }}
password: ${{ secrets.ANTITHESIS_PASSWORD }}
github_token: ${{ secrets.ANTITHESIS_GH_PAT }}
config_image: antithesis-xsvm-config@${{ github.event.inputs.image_tag || 'latest' }}
images: antithesis-xsvm-workload@${{ github.event.inputs.image_tag || 'latest' }};antithesis-xsvm-node@${{ github.event.inputs.image_tag || 'latest' }}
email_recipients: ${{ github.event.inputs.recipients || secrets.ANTITHESIS_RECIPIENTS }}
additional_parameters: |-
custom.duration=${{ github.event.inputs.duration || '0.5' }}
21 changes: 8 additions & 13 deletions vms/platformvm/block/executor/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ func (v *verifier) ApricotProposalBlock(b *block.ApricotProposalBlock) error {
}

var (
staticFeesCfg = v.txExecutorBackend.Config.StaticFeeConfig
upgrades = v.txExecutorBackend.Config.UpgradeConfig
feeCalculator = fee.NewStaticCalculator(staticFeesCfg, upgrades, onCommitState.GetTimestamp())
staticFeeConfig = v.txExecutorBackend.Config.StaticFeeConfig
upgradeConfig = v.txExecutorBackend.Config.UpgradeConfig
timestamp = onCommitState.GetTimestamp() // Equal to parent timestamp
feeCalculator = fee.NewStaticCalculator(staticFeeConfig, upgradeConfig, timestamp)
)
return v.proposalBlock(b, nil, onCommitState, onAbortState, feeCalculator, nil, nil, nil)
}
Expand All @@ -187,9 +188,10 @@ func (v *verifier) ApricotStandardBlock(b *block.ApricotStandardBlock) error {
}

var (
staticFeesCfg = v.txExecutorBackend.Config.StaticFeeConfig
upgrades = v.txExecutorBackend.Config.UpgradeConfig
feeCalculator = fee.NewStaticCalculator(staticFeesCfg, upgrades, onAcceptState.GetTimestamp())
staticFeeConfig = v.txExecutorBackend.Config.StaticFeeConfig
upgradeConfig = v.txExecutorBackend.Config.UpgradeConfig
timestamp = onAcceptState.GetTimestamp() // Equal to parent timestamp
feeCalculator = fee.NewStaticCalculator(staticFeeConfig, upgradeConfig, timestamp)
)
return v.standardBlock(b, feeCalculator, onAcceptState)
}
Expand Down Expand Up @@ -357,9 +359,6 @@ func (v *verifier) abortBlock(b block.Block) error {
statelessBlock: b,
onAcceptState: onAbortState,
timestamp: onAbortState.GetTimestamp(),

// blockComplexity not set. We'll assign same complexity
// as proposal blocks upon acceptance
}
return nil
}
Expand All @@ -377,9 +376,6 @@ func (v *verifier) commitBlock(b block.Block) error {
statelessBlock: b,
onAcceptState: onCommitState,
timestamp: onCommitState.GetTimestamp(),

// blockComplexity not set. We'll assign same complexity
// as proposal blocks upon acceptance
}
return nil
}
Expand Down Expand Up @@ -475,7 +471,6 @@ func (v *verifier) processStandardTxs(txs []*txs.Tx, feeCalculator fee.Calculato
funcs = make([]func(), 0, len(txs))
atomicRequests = make(map[ids.ID]*atomic.Requests)
)

for _, tx := range txs {
txExecutor := executor.StandardTxExecutor{
Backend: v.txExecutorBackend,
Expand Down
10 changes: 6 additions & 4 deletions vms/platformvm/state/chain_time_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ func GetNextStakerChangeTime(state Chain) (time.Time, error) {
}
}

// [PickFeeCalculator] creates either a static or a dynamic fee calculator, depending on the active upgrade
// [PickFeeCalculator] does not modify [state]
// PickFeeCalculator creates either a static or a dynamic fee calculator,
// depending on the active upgrade.
//
// PickFeeCalculator does not modify [state].
func PickFeeCalculator(cfg *config.Config, state Chain) (fee.Calculator, error) {
childBlkTime := state.GetTimestamp()
return fee.NewStaticCalculator(cfg.StaticFeeConfig, cfg.UpgradeConfig, childBlkTime), nil
timestamp := state.GetTimestamp()
return fee.NewStaticCalculator(cfg.StaticFeeConfig, cfg.UpgradeConfig, timestamp), nil
}
4 changes: 1 addition & 3 deletions vms/platformvm/txs/executor/staker_tx_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,10 +762,8 @@ func verifyTransferSubnetOwnershipTx(
var (
currentTimestamp = chainState.GetTimestamp()
upgrades = backend.Config.UpgradeConfig
isDurangoActive = upgrades.IsDurangoActivated(currentTimestamp)
)

if !isDurangoActive {
if !upgrades.IsDurangoActivated(currentTimestamp) {
return ErrDurangoUpgradeNotActive
}

Expand Down
7 changes: 2 additions & 5 deletions vms/platformvm/txs/executor/standard_tx_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,8 @@ func (e *StandardTxExecutor) BaseTx(tx *txs.BaseTx) error {
var (
currentTimestamp = e.State.GetTimestamp()
upgrades = e.Backend.Config.UpgradeConfig
IsDurangoActive = upgrades.IsDurangoActivated(currentTimestamp)
)

if !IsDurangoActive {
if !upgrades.IsDurangoActivated(currentTimestamp) {
return ErrDurangoUpgradeNotActive
}

Expand Down Expand Up @@ -619,13 +617,12 @@ func (e *StandardTxExecutor) BaseTx(tx *txs.BaseTx) error {
func (e *StandardTxExecutor) putStaker(stakerTx txs.Staker) error {
var (
chainTime = e.State.GetTimestamp()
upgrades = e.Backend.Config.UpgradeConfig
txID = e.Tx.ID()
staker *state.Staker
err error
)

if !upgrades.IsDurangoActivated(chainTime) {
if !e.Config.UpgradeConfig.IsDurangoActivated(chainTime) {
// Pre-Durango, stakers set a future [StartTime] and are added to the
// pending staker set. They are promoted to the current staker set once
// the chain time reaches [StartTime].
Expand Down
6 changes: 3 additions & 3 deletions vms/platformvm/txs/txstest/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ func newContext(
timestamp time.Time,
) *builder.Context {
var (
feeCalc = fee.NewStaticCalculator(cfg.StaticFeeConfig, cfg.UpgradeConfig, timestamp)
createSubnetFee, _ = feeCalc.CalculateFee(&txs.Tx{Unsigned: &txs.CreateSubnetTx{}})
createChainFee, _ = feeCalc.CalculateFee(&txs.Tx{Unsigned: &txs.CreateChainTx{}})
feeCalculator = fee.NewStaticCalculator(cfg.StaticFeeConfig, cfg.UpgradeConfig, timestamp)
createSubnetFee, _ = feeCalculator.CalculateFee(&txs.Tx{Unsigned: &txs.CreateSubnetTx{}})
createChainFee, _ = feeCalculator.CalculateFee(&txs.Tx{Unsigned: &txs.CreateChainTx{}})
)

return &builder.Context{
Expand Down

0 comments on commit 2c30347

Please sign in to comment.