Skip to content

Commit

Permalink
rfct/refactor api and node accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiden-araki committed Jan 15, 2025
1 parent d4652fc commit cf16840
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 424 deletions.
146 changes: 0 additions & 146 deletions sequencer/api/api.go

This file was deleted.

46 changes: 0 additions & 46 deletions sequencer/api/config.go

This file was deleted.

27 changes: 0 additions & 27 deletions sequencer/api/coordinatornetwork/coordinatornetwork.go

This file was deleted.

61 changes: 0 additions & 61 deletions sequencer/api/stateapiupdater/stateapiupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"sync"
"tokamak-sybil-resistance/common"
"tokamak-sybil-resistance/database/historydb"
"tokamak-sybil-resistance/log"
)

// Updater is an utility object to facilitate updating the StateAPI
Expand All @@ -26,43 +25,6 @@ type Updater struct {
maxTxPerBatch int64
}

// RecommendedFeePolicy describes how the recommended fee is calculated
type RecommendedFeePolicy struct {
PolicyType RecommendedFeePolicyType `validate:"required" env:"HEZNODE_RECOMMENDEDFEEPOLICY_POLICYTYPE"`
StaticValue float64 `env:"HEZNODE_RECOMMENDEDFEEPOLICY_STATICVALUE"`
BreakThreshold int `env:"HEZNODE_RECOMMENDEDFEEPOLICY_BREAKTHRESHOLD"`
NumLastBatchAvg int `env:"HEZNODE_RECOMMENDEDFEEPOLICY_NUMLASTBATCHAVG"`
}

// RecommendedFeePolicyType describes the different available recommended fee strategies
type RecommendedFeePolicyType string

const (
// RecommendedFeePolicyTypeStatic always give the same StaticValue as recommended fee
RecommendedFeePolicyTypeStatic RecommendedFeePolicyType = "Static"
// RecommendedFeePolicyTypeAvgLastHour set the recommended fee using the average fee of the last hour
RecommendedFeePolicyTypeAvgLastHour RecommendedFeePolicyType = "AvgLastHour"
// RecommendedFeePolicyTypeDynamicFee set the recommended fee taking in account the gas used in L1,
// the gasPrice and the ether price in the last batches
RecommendedFeePolicyTypeDynamicFee RecommendedFeePolicyType = "DynamicFee"
)

func (rfp *RecommendedFeePolicy) valid() bool {
switch rfp.PolicyType {
case RecommendedFeePolicyTypeStatic:
if rfp.StaticValue == 0 {
log.Warn("RecommendedFee is set to 0 USD, and the policy is static")
}
return true
case RecommendedFeePolicyTypeAvgLastHour:
return true
case RecommendedFeePolicyTypeDynamicFee:
return true
default:
return false
}
}

// SetSCVars sets the smart contract vars (ony updates those that are not nil)
func (u *Updater) SetSCVars(vars *common.SCVariablesPtr) {
u.rw.Lock()
Expand All @@ -72,15 +34,6 @@ func (u *Updater) SetSCVars(vars *common.SCVariablesPtr) {
rollupVars := historydb.NewRollupVariablesAPI(u.vars.Rollup)
u.state.Rollup = *rollupVars
}
// if vars.Auction != nil {
// u.vars.Auction = vars.Auction
// auctionVars := historydb.NewAuctionVariablesAPI(u.vars.Auction)
// u.state.Auction = *auctionVars
// }
// if vars.WDelayer != nil {
// u.vars.WDelayer = vars.WDelayer
// u.state.WithdrawalDelayer = *u.vars.WDelayer
// }
}

// NewUpdater creates a new Updater
Expand Down Expand Up @@ -126,18 +79,6 @@ func (u *Updater) UpdateNetworkInfo(
} else if err != nil {
return common.Wrap(err)
}
// u.rw.RLock()
// auctionVars := u.vars.Auction
// u.rw.RUnlock()
// Get next forgers
// lastClosedSlot := currentSlot + int64(auctionVars.ClosedAuctionSlots)
// nextForgers, err := u.hdb.GetNextForgersInternalAPI(auctionVars, &u.consts.Auction,
// lastSyncBlock, currentSlot, lastClosedSlot)
// if common.Unwrap(err) == sql.ErrNoRows {
// nextForgers = nil
// } else if err != nil {
// return common.Wrap(err)
// }

bucketUpdates, err := u.hdb.GetBucketUpdatesInternalAPI()
if err == sql.ErrNoRows {
Expand Down Expand Up @@ -165,8 +106,6 @@ func (u *Updater) UpdateNetworkInfo(
u.state.Network.LastSyncBlock = lastSyncBlock.Num
u.state.Network.LastEthBlock = lastEthBlock.Num
u.state.Network.LastBatch = lastBatch
// u.state.Network.CurrentSlot = currentSlot
// u.state.Network.NextForgers = nextForgers
u.state.Network.PendingL1Txs = pendingL1s
u.rw.Unlock()
return nil
Expand Down
Loading

0 comments on commit cf16840

Please sign in to comment.