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

Astria named forks #59

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 5 additions & 8 deletions consensus/misc/eip1559/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade
// Verify that the gas limit remains within allowed bounds
parentGasLimit := parent.GasLimit
if !config.IsLondon(parent.Number) {
parentGasLimit = parent.GasLimit * config.ElasticityMultiplier(parent.Number.Uint64())
parentGasLimit = parent.GasLimit * config.GetAstriaForks().ElasticityMultiplierAt(parent.Number.Uint64())
}
if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil {
return err
Expand All @@ -60,7 +60,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
return new(big.Int).SetUint64(params.InitialBaseFee)
}

parentGasTarget := parent.GasLimit / config.ElasticityMultiplier(parent.Number.Uint64()+1)
parentGasTarget := parent.GasLimit / config.GetAstriaForks().ElasticityMultiplierAt(parent.Number.Uint64()+1)
// If the parent gasUsed is the same as the target, the baseFee remains unchanged.
if parent.GasUsed == parentGasTarget {
return new(big.Int).Set(parent.BaseFee)
Expand All @@ -77,7 +77,7 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
num.SetUint64(parent.GasUsed - parentGasTarget)
num.Mul(num, parent.BaseFee)
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator(parent.Number.Uint64()+1)))
num.Div(num, denom.SetUint64(config.GetAstriaForks().BaseFeeChangeDenominatorAt(parent.Number.Uint64()+1)))
baseFeeDelta := math.BigMax(num, common.Big1)

return num.Add(parent.BaseFee, baseFeeDelta)
Expand All @@ -87,13 +87,10 @@ func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int {
num.SetUint64(parentGasTarget - parent.GasUsed)
num.Mul(num, parent.BaseFee)
num.Div(num, denom.SetUint64(parentGasTarget))
num.Div(num, denom.SetUint64(config.BaseFeeChangeDenominator(parent.Number.Uint64()+1)))
num.Div(num, denom.SetUint64(config.GetAstriaForks().BaseFeeChangeDenominatorAt(parent.Number.Uint64()+1)))
baseFee := num.Sub(parent.BaseFee, num)

lowerBound := common.Big0
if config.AstriaEIP1559Params != nil {
lowerBound = config.AstriaEIP1559Params.MinBaseFeeAt(parent.Number.Uint64() + 1)
}
lowerBound := config.GetAstriaForks().MinBaseFeeAt(parent.Number.Uint64() + 1)

return math.BigMax(baseFee, lowerBound)
}
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
bc.currentBlock.Store(bc.genesisBlock.Header())
bc.currentFinalBlock.Store(bc.genesisBlock.Header())
bc.currentSafeBlock.Store(bc.genesisBlock.Header())
bc.currentBaseCelestiaHeight.Store(bc.Config().AstriaCelestiaInitialHeight)
bc.currentBaseCelestiaHeight.Store(bc.Config().GetAstriaForks().GetForkAtHeight(1).Celestia.StartHeight)

// Update chain info data metrics
chainInfoGauge.Update(metrics.GaugeInfoValue{"chain_id": bc.chainConfig.ChainID.String()})
Expand Down
4 changes: 2 additions & 2 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (b *BlockGen) AddUncle(h *types.Header) {
if b.cm.config.IsLondon(h.Number) {
h.BaseFee = eip1559.CalcBaseFee(b.cm.config, parent)
if !b.cm.config.IsLondon(parent.Number) {
parentGasLimit := parent.GasLimit * b.cm.config.ElasticityMultiplier(parent.Number.Uint64())
parentGasLimit := parent.GasLimit * b.cm.config.GetAstriaForks().ElasticityMultiplierAt(parent.Number.Uint64())
h.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)
}
}
Expand Down Expand Up @@ -540,7 +540,7 @@ func (cm *chainMaker) makeHeader(parent *types.Block, state *state.StateDB, engi
if cm.config.IsLondon(header.Number) {
header.BaseFee = eip1559.CalcBaseFee(cm.config, parent.Header())
if !cm.config.IsLondon(parent.Number()) {
parentGasLimit := parent.GasLimit() * cm.config.ElasticityMultiplier(parent.Number().Uint64())
parentGasLimit := parent.GasLimit() * cm.config.GetAstriaForks().ElasticityMultiplierAt(parent.Number().Uint64())
header.GasLimit = CalcGasLimit(parentGasLimit, parentGasLimit)
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (g *Genesis) ToBlock() *types.Block {

extraData := g.ExtraData
if g.Config.AstriaOverrideGenesisExtraData {
extraData = g.Config.AstriaExtraData()
extraData = g.Config.AstriaExtraData(1)
}

head := &types.Header{
Expand Down
2 changes: 1 addition & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig

// Set up precompiles
evm.precompileManager = NewPrecompileManager(evm)
evm.precompileManager.RegisterMap(pconfig.PrecompileConfig(chainConfig, blockCtx.BlockNumber.Uint64(), blockCtx.Time))
evm.precompileManager.RegisterMap(pconfig.GetPrecompiles(chainConfig, blockCtx.BlockNumber.Uint64(), blockCtx.Time))

return evm
}
Expand Down
27 changes: 16 additions & 11 deletions dev/geth-genesis-local.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,22 @@
"ethash": {},
"astriaRollupName": "astria-test-chain-1",
"astriaOverrideGenesisExtraData": true,
"astriaSequencerInitialHeight": 2,
"astriaSequencerAddressPrefix": "astria",
"astriaCelestiaInitialHeight": 2,
"astriaCelestiaHeightVariance": 10,
"astriaBridgeAddresses": [],
"astriaBridgeSenderAddress": "0x0000000000000000000000000000000000000000",
"astriaFeeCollectors": {
"1": "0xaC21B97d35Bf75A7dAb16f35b111a50e78A72F30"
},
"astriaEIP1559Params": {
"1": { "minBaseFee": 0, "elasticityMultiplier": 2, "BaseFeeChangeDenominator": 8 }
"astriaForks": {
"testLaunch": {
"height": 1,
"feeCollector": "0xaC21B97d35Bf75A7dAb16f35b111a50e78A72F30",
"eip1559Params": { "minBaseFee": 0, "elasticityMultiplier": 2, "BaseFeeChangeDenominator": 8 },
"sequencer": {
"chainId": "sequencer-test-chain-0",
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just used for genesis validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is a justfile in the dev directory too which is used in our tutorials on running a local rollup. These are the default values needed if you follow the tutorial.

"addressPrefix": "astria",
"startHeight": 2
},
"celestia": {
"chainId": "mocha-4",
"startHeight": 2,
"heightVariance": 10
}
}
}
},
"difficulty": "10000000",
Expand Down
1 change: 0 additions & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
}

eth.miner = miner.New(eth, config.Miner, eth.engine)
eth.miner.SetExtra(chainConfig.AstriaExtraData())

eth.APIBackend = &EthAPIBackend{stack.Config().ExtRPCEnabled(), stack.Config().AllowUnprotectedTxs, eth, nil}
if eth.APIBackend.allowUnprotectedTxs {
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/ethereum/go-ethereum
go 1.21

require (
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-20241017141511-7e4bcc0ebba5.1
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-20241017141511-7e4bcc0ebba5.1
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-20240911152449-eeebd3decdce.1
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-20241017141511-71aab1871615.1
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-000acc99835d.2
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.5-00000000000000-000acc99835d.1
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.5-00000000000000-43fac4060faa.1
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.5-00000000000000-460c09199479.1
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
github.com/Microsoft/go-winio v0.6.1
github.com/VictoriaMetrics/fastcache v1.12.1
Expand Down Expand Up @@ -79,7 +79,7 @@ require (
golang.org/x/time v0.5.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
google.golang.org/grpc v1.64.1
google.golang.org/protobuf v1.35.1
google.golang.org/protobuf v1.36.5
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-20241017141511-7e4bcc0ebba5.1 h1:v7QnrDjNmG7I/0aqZdtlP3cBPQGd62w4AYVF8TfAcHM=
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-20241017141511-7e4bcc0ebba5.1/go.mod h1:T5EsLvEE5UMk62gVSwNY/7XlxknAP3sL8tYRsU68b4s=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-20241017141511-7e4bcc0ebba5.1 h1:3G2O21DuY5Y/G32tP1mAI16AxwDYTscG2YaOb/WQty0=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.35.1-20241017141511-7e4bcc0ebba5.1/go.mod h1:U4LUlabiYNYBd1pqYS9o8SsHjBRoEBysrfRVnebzJH0=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-20240911152449-eeebd3decdce.1 h1:kG4riHqlF9X6iZ1Oxs5/6ul6aue7MS+A6DK6HAchuTk=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.35.1-20240911152449-eeebd3decdce.1/go.mod h1:n9L7X3VAj4od4VHf2ScJuHARUUQTSxJqtRHZk/7Ptt0=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-20241017141511-71aab1871615.1 h1:hPMoxTiT7jJjnIbWqneBbL05VeVOTD9UeC/qdvzHL8g=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.35.1-20241017141511-71aab1871615.1/go.mod h1:2uasRFMH+a3DaF34c1o+w7/YtYnoknmARyYpb9W2QIc=
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-000acc99835d.2 h1:4/8fPnl5TMRTMVFLYbbV6ydF2iHVHAne59g8n7Gc5HE=
buf.build/gen/go/astria/execution-apis/grpc/go v1.5.1-00000000000000-000acc99835d.2/go.mod h1:0hRaAtELfUy1TJRk8xC0NrRAfYnWz8n9Oxi0+tmiTDE=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.5-00000000000000-000acc99835d.1 h1:H59mAQwZWpL09jtRy8X1ZiIVHT8xy78E/G9MqK2U8oI=
buf.build/gen/go/astria/execution-apis/protocolbuffers/go v1.36.5-00000000000000-000acc99835d.1/go.mod h1:qRn+inLSaOctJRFezWQNhWVtJUD+v92SqW7wBcIAraQ=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.5-00000000000000-43fac4060faa.1 h1:+ujbh3s70Q8Ol38rh4ypZU0K24xUExjOri28WBRvYRs=
buf.build/gen/go/astria/primitives/protocolbuffers/go v1.36.5-00000000000000-43fac4060faa.1/go.mod h1:1Yy42OW1qdHTCWq9sfiJD8ZJCRqEL6xc2fBppEyNF0k=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.5-00000000000000-460c09199479.1 h1:4DIdccREjdKMiTaNTGBqf4CyuNjJInwYh3MFyCjR3hI=
buf.build/gen/go/astria/sequencerblock-apis/protocolbuffers/go v1.36.5-00000000000000-460c09199479.1/go.mod h1:oJ5ZsJPnuwq8FTAB2/C107jxbKUmOOJvpXvjUE4fAN0=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
Expand Down Expand Up @@ -895,8 +895,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
120 changes: 46 additions & 74 deletions grpc/execution/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/params"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/timestamppb"
Expand All @@ -45,11 +44,6 @@ type ExecutionServiceServerV1 struct {

genesisInfoCalled bool
getCommitmentStateCalled bool

bridgeAddresses map[string]*params.AstriaBridgeAddressConfig // astria bridge addess to config for that bridge account
bridgeAllowedAssets map[string]struct{} // a set of allowed asset IDs structs are left empty

nextFeeRecipient common.Address // Fee recipient for the next block
}

var (
Expand Down Expand Up @@ -81,74 +75,35 @@ func NewExecutionServiceServerV1(eth *eth.Ethereum) (*ExecutionServiceServerV1,
return nil, errors.New("rollup name not set")
}

if bc.Config().AstriaSequencerInitialHeight == 0 {
fork := bc.Config().GetAstriaForks().GetForkAtHeight(max(bc.CurrentSafeBlock().Number.Uint64(), 1))

if fork.Sequencer.ChainID == "" {
return nil, errors.New("sequencer chain ID not set")
}

if fork.Sequencer.StartHeight == 0 {
return nil, errors.New("sequencer initial height not set")
}

if bc.Config().AstriaCelestiaInitialHeight == 0 {
return nil, errors.New("celestia initial height not set")
if fork.Celestia.ChainID == "" {
return nil, errors.New("celestia chain ID not set")
}

if bc.Config().AstriaCelestiaHeightVariance == 0 {
return nil, errors.New("celestia height variance not set")
if fork.Celestia.StartHeight == 0 {
return nil, errors.New("celestia initial height not set")
}

bridgeAddresses := make(map[string]*params.AstriaBridgeAddressConfig)
bridgeAllowedAssets := make(map[string]struct{})
if bc.Config().AstriaBridgeAddressConfigs == nil {
log.Warn("bridge addresses not set")
} else {
nativeBridgeSeen := false
for _, cfg := range bc.Config().AstriaBridgeAddressConfigs {
err := cfg.Validate(bc.Config().AstriaSequencerAddressPrefix)
if err != nil {
return nil, fmt.Errorf("invalid bridge address config: %w", err)
}

if cfg.Erc20Asset == nil {
if nativeBridgeSeen {
return nil, errors.New("only one native bridge address is allowed")
}
nativeBridgeSeen = true
}

if cfg.Erc20Asset != nil && cfg.SenderAddress == (common.Address{}) {
return nil, errors.New("astria bridge sender address must be set for bridged ERC20 assets")
}

bridgeCfg := cfg
bridgeAddresses[cfg.BridgeAddress] = &bridgeCfg
bridgeAllowedAssets[cfg.AssetDenom] = struct{}{}
if cfg.Erc20Asset == nil {
log.Info("bridge for sequencer native asset initialized", "bridgeAddress", cfg.BridgeAddress, "assetDenom", cfg.AssetDenom)
} else {
log.Info("bridge for ERC20 asset initialized", "bridgeAddress", cfg.BridgeAddress, "assetDenom", cfg.AssetDenom, "contractAddress", cfg.Erc20Asset.ContractAddress)
}
}
if fork.Celestia.HeightVariance == 0 {
return nil, errors.New("celestia height variance not set")
}

// To decrease compute cost, we identify the next fee recipient at the start
// and update it as we execute blocks.
nextFeeRecipient := common.Address{}
if bc.Config().AstriaFeeCollectors == nil {
if fork.FeeCollector == (common.Address{}) {
log.Warn("fee asset collectors not set, assets will be burned")
} else {
maxHeightCollectorMatch := uint32(0)
nextBlock := uint32(bc.CurrentBlock().Number.Int64()) + 1
for height, collector := range bc.Config().AstriaFeeCollectors {
if height <= nextBlock && height > maxHeightCollectorMatch {
maxHeightCollectorMatch = height
nextFeeRecipient = collector
}
}
}

return &ExecutionServiceServerV1{
eth: eth,
bc: bc,
bridgeAddresses: bridgeAddresses,
bridgeAllowedAssets: bridgeAllowedAssets,
nextFeeRecipient: nextFeeRecipient,
eth: eth,
bc: bc,
}, nil
}

Expand All @@ -159,10 +114,18 @@ func (s *ExecutionServiceServerV1) GetGenesisInfo(ctx context.Context, req *astr
rollupHash := sha256.Sum256([]byte(s.bc.Config().AstriaRollupName))
rollupId := primitivev1.RollupId{Inner: rollupHash[:]}

fork := s.bc.Config().GetAstriaForks().GetForkAtHeight(s.bc.CurrentSafeBlock().Number.Uint64() + 1)
nextFork := s.bc.Config().GetAstriaForks().GetNextForkAtHeight(s.bc.CurrentSafeBlock().Number.Uint64() + 1)

res := &astriaPb.GenesisInfo{
RollupId: &rollupId,
SequencerGenesisBlockHeight: s.bc.Config().AstriaSequencerInitialHeight,
CelestiaBlockVariance: s.bc.Config().AstriaCelestiaHeightVariance,
RollupId: &rollupId,
SequencerChainId: fork.Sequencer.ChainID,
SequencerStartHeight: fork.Sequencer.StartHeight,
CelestiaChainId: fork.Celestia.ChainID,
CelestiaBlockVariance: fork.Celestia.HeightVariance,
RollupStartBlockNumber: fork.Height,
RollupStopBlockNumber: fork.StopHeight,
HaltAtRollupStopNumber: nextFork != nil && nextFork.Halt,
}

log.Info("GetGenesisInfo completed", "response", res)
Expand Down Expand Up @@ -242,6 +205,7 @@ func (s *ExecutionServiceServerV1) ExecuteBlock(ctx context.Context, req *astria

s.blockExecutionLock.Lock()
defer s.blockExecutionLock.Unlock()

// Deliberately called after lock, to more directly measure the time spent executing
executionStart := time.Now()
defer executeBlockTimer.UpdateSince(executionStart)
Expand All @@ -250,19 +214,26 @@ func (s *ExecutionServiceServerV1) ExecuteBlock(ctx context.Context, req *astria
return nil, status.Error(codes.PermissionDenied, "Cannot execute block until GetGenesisInfo && GetCommitmentState methods are called")
}

// the height that this block will be at
height := s.bc.CurrentBlock().Number.Uint64() + 1

fork := s.bc.Config().GetAstriaForks().GetForkAtHeight(height)

// this fork halts the chain
if fork.Halt {
return nil, status.Error(codes.FailedPrecondition, "Block cannot be created at halted fork")
}
Comment on lines +222 to +225
Copy link
Contributor

Choose a reason for hiding this comment

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

how does the chain un-halt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

manual intervention

Copy link
Contributor

Choose a reason for hiding this comment

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

could you link the doc for this? i'm unclear from the code as to how unhalting would work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes need to get some docs on this but basically the way it would work, such as the case of a sequencer network change, is you would pick some future height to halt at, update genesis to create a new named fork at that future height with halt set to true. Once the rollup reaches this height, it will stop. Then you do whatever manual steps you may need to do to prepare for the chain to migrate. e.g, updating conductor configs, taking any snapshots, etc. Then you update the geth genesis to set halt at this fork to false and set anything else you maybe did not know ahead of the halt, re-init and and start processing blocks.


// Validate block being created has valid previous hash
prevHeadHash := common.BytesToHash(req.PrevBlockHash)
softHash := s.bc.CurrentSafeBlock().Hash()
if prevHeadHash != softHash {
return nil, status.Error(codes.FailedPrecondition, "Block can only be created on top of soft block.")
}

// the height that this block will be at
height := s.bc.CurrentBlock().Number.Uint64() + 1

txsToProcess := types.Transactions{}
for _, tx := range req.Transactions {
unmarshalledTx, err := validateAndUnmarshalSequencerTx(height, tx, s.bridgeAddresses, s.bridgeAllowedAssets)
unmarshalledTx, err := validateAndUnmarshalSequencerTx(height, tx, fork.BridgeAddresses, fork.BridgeAllowedAssets)
if err != nil {
log.Debug("failed to validate sequencer tx, ignoring", "tx", tx, "err", err)
continue
Expand All @@ -274,12 +245,15 @@ func (s *ExecutionServiceServerV1) ExecuteBlock(ctx context.Context, req *astria
// the Miner when building a payload.
s.eth.TxPool().SetAstriaOrdered(txsToProcess)

// set extra data
s.eth.Miner().SetExtra(s.bc.Config().AstriaExtraData(height))

// Build a payload to add to the chain
payloadAttributes := &miner.BuildPayloadArgs{
Parent: prevHeadHash,
Timestamp: uint64(req.GetTimestamp().GetSeconds()),
Random: common.Hash{},
FeeRecipient: s.nextFeeRecipient,
FeeRecipient: s.bc.Config().GetAstriaForks().GetForkAtHeight(height).FeeCollector,
}
payload, err := s.eth.Miner().BuildPayload(payloadAttributes)
if err != nil {
Expand Down Expand Up @@ -312,10 +286,6 @@ func (s *ExecutionServiceServerV1) ExecuteBlock(ctx context.Context, req *astria
},
}

if next, ok := s.bc.Config().AstriaFeeCollectors[res.Number+1]; ok {
s.nextFeeRecipient = next
}

log.Info("ExecuteBlock completed", "block_num", res.Number, "timestamp", res.Timestamp)
totalExecutedTxCount.Inc(int64(len(block.Transactions())))
executeBlockSuccessCount.Inc(1)
Expand All @@ -340,10 +310,12 @@ func (s *ExecutionServiceServerV1) GetCommitmentState(ctx context.Context, req *

celestiaBlock := s.bc.CurrentBaseCelestiaHeight()

fork := s.bc.Config().GetAstriaForks().GetForkAtHeight(uint64(softBlock.Number))

res := &astriaPb.CommitmentState{
Soft: softBlock,
Firm: firmBlock,
BaseCelestiaHeight: celestiaBlock,
BaseCelestiaHeight: max(celestiaBlock, fork.Celestia.StartHeight),
}

log.Info("GetCommitmentState completed", "soft_height", res.Soft.Number, "firm_height", res.Firm.Number, "base_celestia_height", res.BaseCelestiaHeight)
Expand Down
Loading