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

Undo the replay binary #226

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 0 additions & 10 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"strings"
"time"

lightclient "github.com/EspressoSystems/espresso-sequencer-go/light-client"
flag "github.com/spf13/pflag"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -573,18 +572,9 @@ func createNodeImpl(

var statelessBlockValidator *staker.StatelessBlockValidator
if config.BlockValidator.RedisValidationClientConfig.Enabled() || config.BlockValidator.ValidationServerConfigs[0].URL != "" {
var lightClientReader *lightclient.LightClientReader
if config.BlockValidator.Espresso {
addr := common.HexToAddress(config.BlockValidator.LightClientAddress)
lightClientReader, err = lightclient.NewLightClientReader(addr, l1client)
if err != nil {
return nil, err
}
}
statelessBlockValidator, err = staker.NewStatelessBlockValidator(
inboxReader,
inboxTracker,
lightClientReader,
txStreamer,
exec,
rawdb.NewTable(arbDb, storage.BlockValidatorPrefix),
Expand Down
439 changes: 251 additions & 188 deletions cmd/deploy/deploy.go

Large diffs are not rendered by default.

41 changes: 0 additions & 41 deletions cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"

espressoTypes "github.com/EspressoSystems/espresso-sequencer-go/types"
"github.com/offchainlabs/nitro/arbos"
"github.com/offchainlabs/nitro/arbos/arbosState"
"github.com/offchainlabs/nitro/arbos/arbostypes"
Expand All @@ -33,7 +32,6 @@ import (
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/das/dastree"
"github.com/offchainlabs/nitro/espressocrypto"
"github.com/offchainlabs/nitro/gethhook"
"github.com/offchainlabs/nitro/wavmio"
)
Expand Down Expand Up @@ -285,45 +283,6 @@ func main() {
batchFetcher := func(batchNum uint64) ([]byte, error) {
return wavmio.ReadInboxMessage(batchNum), nil
}

// Handle the various pre-conditions if the message is an Espresso message
validatingAgainstEspresso := chainConfig.ArbitrumChainParams.EnableEspresso && arbos.IsEspressoMsg(message.Message)
if validatingAgainstEspresso {
txs, jst, err := arbos.ParseEspressoMsg(message.Message)
if err != nil {
panic(err)
}
if jst == nil {
panic("batch missing espresso justification")
}

hotshotHeader := jst.Header
height := hotshotHeader.Height

if jst.BlockMerkleJustification == nil {
panic("block merkle justification missing")
}

if jst.Proof == nil && len(txs) != 0 {
panic("namespace proof missing")
}

commitment := espressoTypes.Commitment(wavmio.ReadHotShotCommitment(height))
jsonHeader, err := json.Marshal(hotshotHeader)
if err != nil {
panic("unable to serialize header")
}
espressocrypto.VerifyMerkleProof(
jst.BlockMerkleJustification.BlockMerkleProof.Proof,
jsonHeader,
*jst.BlockMerkleJustification.BlockMerkleComm,
commitment,
)
if jst.Proof != nil {
espressocrypto.VerifyNamespace(chainConfig.ChainID.Uint64(), *jst.Proof, *jst.Header.PayloadCommitment, *jst.Header.NsTable, txs, *jst.VidCommon)
}

}
newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, batchFetcher, false)
if err != nil {
panic(err)
Expand Down
12 changes: 6 additions & 6 deletions deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReade
return bridgeCreatorAddr, nil
}

func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, hotshot common.Address) (common.Address, common.Address, error) {
func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts) (common.Address, common.Address, error) {
client := l1Reader.Client()
osp0, tx, _, err := ospgen.DeployOneStepProver0(auth, client)
err = andTxSucceeded(ctx, l1Reader, tx, err)
Expand All @@ -140,7 +140,7 @@ func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderRe
return common.Address{}, common.Address{}, fmt.Errorf("ospMath deploy error: %w", err)
}

ospHostIo, tx, _, err := ospgen.DeployOneStepProverHostIo(auth, client, hotshot)
ospHostIo, tx, _, err := ospgen.DeployOneStepProverHostIo(auth, client, common.Address{})
err = andTxSucceeded(ctx, l1Reader, tx, err)
if err != nil {
return common.Address{}, common.Address{}, fmt.Errorf("ospHostIo deploy error: %w", err)
Expand All @@ -161,13 +161,13 @@ func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderRe
return ospEntryAddr, challengeManagerAddr, nil
}

func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int, hotshot common.Address, isUsingFeeToken bool) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int, isUsingFeeToken bool) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) {
bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth, maxDataSize, isUsingFeeToken)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err)
}

ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, l1Reader, auth, hotshot)
ospEntryAddr, challengeManagerAddr, err := deployChallengeFactory(ctx, l1Reader, auth)
if err != nil {
return nil, common.Address{}, common.Address{}, common.Address{}, err
}
Expand Down Expand Up @@ -234,12 +234,12 @@ func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReade
return rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, nil
}

func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPosters []common.Address, batchPosterManager common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int, hotshot common.Address, isUsingFeeToken bool) (*chaininfo.RollupAddresses, error) {
func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPosters []common.Address, batchPosterManager common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int, isUsingFeeToken bool) (*chaininfo.RollupAddresses, error) {
if config.WasmModuleRoot == (common.Hash{}) {
return nil, errors.New("no machine specified")
}

rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, hotshot, isUsingFeeToken)
rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, isUsingFeeToken)
if err != nil {
return nil, fmt.Errorf("error deploying rollup creator: %w", err)
}
Expand Down
32 changes: 2 additions & 30 deletions staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import (
"testing"
"time"

espressoTypes "github.com/EspressoSystems/espresso-sequencer-go/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp"
"github.com/offchainlabs/nitro/arbnode/resourcemanager"
"github.com/offchainlabs/nitro/arbos"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/util/containers"
"github.com/offchainlabs/nitro/util/rpcclient"
Expand Down Expand Up @@ -108,10 +106,6 @@ type BlockValidatorConfig struct {
ValidationServerConfigsList string `koanf:"validation-server-configs-list"`

memoryFreeLimit int

// Espresso specific flags
Espresso bool `koanf:"espresso"`
LightClientAddress string `koanf:"light-client-address"` //nolint
}

func (c *BlockValidatorConfig) Validate() error {
Expand Down Expand Up @@ -159,9 +153,7 @@ func BlockValidatorConfigAddOptions(prefix string, f *pflag.FlagSet) {
f.Uint64(prefix+".prerecorded-blocks", DefaultBlockValidatorConfig.PrerecordedBlocks, "record that many blocks ahead of validation (larger footprint)")
f.String(prefix+".current-module-root", DefaultBlockValidatorConfig.CurrentModuleRoot, "current wasm module root ('current' read from chain, 'latest' from machines/latest dir, or provide hash)")
f.String(prefix+".pending-upgrade-module-root", DefaultBlockValidatorConfig.PendingUpgradeModuleRoot, "pending upgrade wasm module root to additionally validate (hash, 'latest' or empty)")
f.String(prefix+".light-client-address", DefaultBlockValidatorConfig.LightClientAddress, "address of the hotshot light client contract")
f.Bool(prefix+".failure-is-fatal", DefaultBlockValidatorConfig.FailureIsFatal, "failing a validation is treated as a fatal error")
f.Bool(prefix+".espresso", DefaultBlockValidatorConfig.Espresso, "if true, hotshot header preimages will be added to validation entries to verify that transactions have been sequenced by espresso")
BlockValidatorDangerousConfigAddOptions(prefix+".dangerous", f)
f.String(prefix+".memory-free-limit", DefaultBlockValidatorConfig.MemoryFreeLimit, "minimum free-memory limit after reaching which the blockvalidator pauses validation. Enabled by default as 1GB, to disable provide empty string")
}
Expand Down Expand Up @@ -440,7 +432,7 @@ func GlobalStateToMsgCount(tracker InboxTrackerInterface, streamer TransactionSt
return false, 0, err
}
if res.BlockHash != gs.BlockHash || res.SendRoot != gs.SendRoot {
return false, count, fmt.Errorf("%w: count %d hash %v expected %v, sendroot %v expected %v", ErrGlobalStateNotInChain, count, gs.BlockHash, res.BlockHash, gs.SendRoot, res.SendRoot)
return false, 0, fmt.Errorf("%w: count %d hash %v expected %v, sendroot %v expected %v", ErrGlobalStateNotInChain, count, gs.BlockHash, res.BlockHash, gs.SendRoot, res.SendRoot)
}
return true, count, nil
}
Expand Down Expand Up @@ -582,29 +574,9 @@ func (v *BlockValidator) createNextValidationEntry(ctx context.Context) (bool, e
} else {
return false, fmt.Errorf("illegal batch msg count %d pos %d batch %d", v.nextCreateBatchMsgCount, pos, endGS.Batch)
}
var comm espressoTypes.Commitment
var isHotShotLive bool
var blockHeight uint64
if arbos.IsEspressoMsg(msg.Message) {
_, jst, err := arbos.ParseEspressoMsg(msg.Message)
if err != nil {
return false, err
}
blockHeight = jst.Header.Height
snapShot, err := v.lightClientReader.FetchMerkleRoot(blockHeight, nil)
if err != nil {
log.Error("error attempting to fetch block merkle root from the light client contract", "blockHeight", blockHeight)
return false, err
}
comm = snapShot.Root
isHotShotLive = true
} else if arbos.IsL2NonEspressoMsg(msg.Message) {
isHotShotLive = false
blockHeight = msg.Message.Header.BlockNumber
}
chainConfig := v.streamer.ChainConfig()
entry, err := newValidationEntry(
pos, v.nextCreateStartGS, endGS, msg, v.nextCreateBatch, v.nextCreateBatchBlockHash, v.nextCreatePrevDelayed, chainConfig, &comm, isHotShotLive, blockHeight,
pos, v.nextCreateStartGS, endGS, msg, v.nextCreateBatch, v.nextCreateBatchBlockHash, v.nextCreatePrevDelayed, chainConfig,
)
if err != nil {
return false, err
Expand Down
Loading
Loading