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

Parallel decryptions #128

Merged
merged 84 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3504d8c
Parallel decryptions: DecryptionResults (#124)
toml01 Aug 13, 2024
d9d0d3b
just minor import changes
toml01 Aug 21, 2024
d9160aa
geth version with custom txprocessinghooks
toml01 Aug 25, 2024
c9e2f86
Add ParallelTxHooks to TxParams
toml01 Aug 25, 2024
8574901
fix build?
toml01 Aug 25, 2024
ab99728
update overrides
toml01 Aug 27, 2024
d17f239
fix build
toml01 Sep 2, 2024
2da1391
update the Get() function to delegate the type assertion to the caller
toml01 Sep 3, 2024
169b585
type compatibility
toml01 Sep 3, 2024
e1d1cdf
fix tests
toml01 Sep 3, 2024
8c34dde
implement the decrypt precomp
toml01 Sep 3, 2024
323192f
added fheos serialization for decryption results
eshelB Sep 8, 2024
c02cea3
serialize flow finished+ added loadMultiple results
eshelB Sep 8, 2024
ddad1ff
added first serialization test
eshelB Sep 8, 2024
22ce2bc
update geth
toml01 Sep 9, 2024
7ed36a3
update the Get() function to delegate the type assertion to the caller
toml01 Sep 3, 2024
a839ada
type compatibility
toml01 Sep 3, 2024
24170e7
fix tests
toml01 Sep 3, 2024
4bd4b42
implement the decrypt precomp
toml01 Sep 3, 2024
8215b54
implement req() and sealoutput() as well
toml01 Sep 4, 2024
2c19a1e
just override stuff for CI
toml01 Sep 5, 2024
a5944c2
added compatibility for non-sequencer nodes too
toml01 Sep 5, 2024
d77e5b6
restructure req, sealoutput and decrypt to allow sync operation in qu…
toml01 Sep 5, 2024
268aaeb
Change precompiles to play nice with contracts_parser.ts
toml01 Sep 5, 2024
a8c556a
fix expected type for sealoutput
toml01 Sep 9, 2024
018f3d9
overrides for CI
toml01 Sep 9, 2024
c039422
use deep copies for function arguments
toml01 Sep 9, 2024
797e369
Create a unique PendingDecryption key for sealing output for each pub…
toml01 Sep 10, 2024
31d1f02
fix build
toml01 Sep 10, 2024
db7f1d4
better comment
toml01 Sep 10, 2024
51938f4
update the Get() function to delegate the type assertion to the caller
toml01 Sep 3, 2024
e6b1b16
type compatibility
toml01 Sep 3, 2024
b86a54a
fix tests
toml01 Sep 3, 2024
938d579
remove comment
toml01 Sep 10, 2024
5f2e90d
Merge branch 'pd-sequencer-flow' into sync-tx-results
eshelB Sep 11, 2024
9e132ee
Merge pull request #133 from FhenixProtocol/pd-sequencer-flow
toml01 Sep 11, 2024
f00a87d
Merge pull request #137 from FhenixProtocol/pd-new-structs-2
toml01 Sep 11, 2024
61191b1
Merge branch 'parallel-decrypts' into pd-precompiles
toml01 Sep 11, 2024
b97abe9
Merge branch 'pd-precompiles' into sync-tx-results-3
eshelB Sep 12, 2024
095558c
adding nitro-overrides parse_l2.go and executionegine.go, updating bl…
eshelB Sep 11, 2024
7113bda
added nitro-overrides to dockerfile
eshelB Sep 11, 2024
7a51719
using the go-ethereum version of pd-precompiles
eshelB Sep 12, 2024
6eb2be7
removing ontxsuccess
eshelB Sep 12, 2024
8d6c500
changed expected type for sealoutput result serialization to be strin…
eshelB Sep 12, 2024
eab219c
Merge branch 'pd-precompiles' into sync-tx-results
eshelB Sep 12, 2024
53c6324
now parallel goroutine waits for txqueueitem to exist
eshelB Sep 15, 2024
5890c58
adding a nitro override
eshelB Sep 15, 2024
34f4da5
fixing sequencer bug on notifyDecResult and documenting potential issue
eshelB Sep 15, 2024
aa454ee
fixing re-close channel bug
eshelB Sep 15, 2024
38c80e9
Merge branch 'pd-delegate-test-fix' into sync-tx-results
eshelB Sep 15, 2024
180df97
restoring dockerfile local change
eshelB Sep 15, 2024
2671908
adding a nitro override
eshelB Sep 15, 2024
0b2fb8f
updating overrides
eshelB Sep 15, 2024
79f74d5
forgot one bytes to string conversion
eshelB Sep 15, 2024
ca4324a
removing todo
eshelB Sep 15, 2024
2ece2f5
Merge pull request #138 from FhenixProtocol/pd-precompiles
toml01 Sep 16, 2024
53d0a5f
nitro overrides
eshelB Sep 16, 2024
7b47439
Merge branch 'parallel-decrypts' of github.com:FhenixProtocol/fheos i…
eshelB Sep 16, 2024
9f0146f
adding debug log
eshelB Sep 18, 2024
fea1d1d
CI: refactoring common code into function
eshelB Sep 18, 2024
42bb41a
adding minor change in override
eshelB Sep 18, 2024
a807ac1
resolve conflicts
toml01 Sep 18, 2024
f9b7b8d
fix log lib
toml01 Sep 18, 2024
b924b74
propagate tx hash to precompiles through TxContext
toml01 Sep 19, 2024
1143e85
Use txHash instead of blockHash in auto-seeding
toml01 Sep 19, 2024
1387526
Update the nitro fix (override)
toml01 Sep 18, 2024
1fd351b
update geth
toml01 Sep 22, 2024
d99280d
use block hash for non-commit calls
toml01 Sep 22, 2024
0d5f6ec
remove lastSavedHash from fheos state
toml01 Sep 22, 2024
324bb2e
Merge branch 'parallel-decrypts' into pd-sync-results
eshelB Sep 23, 2024
0001764
Merge pull request #152 from FhenixProtocol/rand-ct-deterministic-hash
toml01 Sep 23, 2024
0e0939a
updating nitro-override
eshelB Sep 23, 2024
e167b94
Merge remote-tracking branch 'origin/parallel-decrypts' into pd-sync-…
eshelB Sep 23, 2024
266d5c8
Merge pull request #146 from FhenixProtocol/pd-sync-results
toml01 Sep 24, 2024
9712c01
Update go-ethereum
toml01 Sep 24, 2024
0839294
fix nitro tests
toml01 Sep 24, 2024
d6f2813
sync with master
toml01 Sep 24, 2024
345632d
mastermain-synced geth
toml01 Sep 24, 2024
d2f81a1
update geth to support celestia
toml01 Sep 25, 2024
023b4e7
update geth with celestia merge
toml01 Sep 25, 2024
ff101ca
update geth
toml01 Sep 26, 2024
46ccfc5
Update docker base image for tests
toml01 Sep 29, 2024
74c7994
Merge pull request #155 from FhenixProtocol/celestia-merge
toml01 Sep 30, 2024
7e8efa2
update geth
toml01 Sep 30, 2024
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*/node_modules/*
precompiles/cache/*
precompiles/types/*
precompiles/artifacts/*
solgen/**/*.js
build/
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BRANCH=latest
ARG BRANCH=v0.0.0-alpha.10
ARG DOCKER_NAME=ghcr.io/fhenixprotocol/nitro/fhenix-node-builder:$BRANCH

FROM rust:1.74-slim-bullseye as warp-drive-builder
Expand Down Expand Up @@ -77,8 +77,6 @@ RUN ./gen.sh

WORKDIR /workspace

COPY nitro-overrides/precompiles/FheOps.go precompiles/FheOps.go

RUN go mod tidy

RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest
Expand Down
16 changes: 8 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ func initFheos() (*precompiles.TxParams, error) {
}

tp := precompiles.TxParams{
false,
false,
true,
nil,
common.HexToAddress("0x0000000000000000000000000000000000000000"),
vm.GetHashFunc(nil),
nil,
}
Commit: false,
GasEstimation: false,
EthCall: true,
CiphertextDb: nil,
ContractAddress: common.HexToAddress("0x0000000000000000000000000000000000000000"),
GetBlockHash: vm.GetHashFunc(nil),
BlockNumber: nil,
ParallelTxHooks: nil}

return &tp, err
}
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw=
github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4=
github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
Expand Down
5 changes: 5 additions & 0 deletions hooks/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package hooks

import (
"encoding/hex"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -153,6 +154,10 @@ func (h FheOSHooksImpl) EvmCallEnd(evmSuccess bool) {
log.Info("Deleted ciphertext", "hash", hex.EncodeToString(hash[:]))
}
}

if fheos.State != nil {
fheos.State.RandomCounter = 0
}
}

func shouldIgnoreContract(caller common.Address, addr common.Address) bool {
Expand Down
96 changes: 96 additions & 0 deletions nitro-overrides/cmd/staterecovery/staterecovery.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package staterecovery

import (
"fmt"
"time"

"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/triedb"
"github.com/ethereum/go-ethereum/triedb/hashdb"
)

func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error {
start := time.Now()
currentHeader := bc.CurrentBlock()
if currentHeader == nil {
return fmt.Errorf("current header is nil")
}
target := currentHeader.Number.Uint64()
current := startBlock
genesis := bc.Config().ArbitrumChainParams.GenesisBlockNum
if current < genesis+1 {
current = genesis + 1
log.Warn("recreate-missing-states-from before genesis+1, starting from genesis+1", "configured", startBlock, "override", current)
}
previousBlock := bc.GetBlockByNumber(current - 1)
if previousBlock == nil {
return fmt.Errorf("start block parent is missing, parent block number: %d", current-1)
}

if cacheConfig.StateScheme == rawdb.PathScheme {
return fmt.Errorf("recreating missing states, which is supposed to only run in archive mode, is not supported with path scheme")
}

hashConfig := *hashdb.Defaults
hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024
trieConfig := &triedb.Config{
Preimages: false,
HashDB: &hashConfig,
}

database := state.NewDatabaseWithConfig(chainDb, trieConfig)
defer database.TrieDB().Close()
previousState, err := state.New(previousBlock.Root(), database, nil)
if err != nil {
return fmt.Errorf("state of start block parent is missing: %w", err)
}
// we don't need to reference states with `trie.Database.Reference` here, because:
// * either the state nodes will be read from disk and then cached in cleans cache
// * or they will be recreated, saved to disk and then also cached in cleans cache
logged := time.Unix(0, 0)
recreated := 0
for {
currentBlock := bc.GetBlockByNumber(current)
if currentBlock == nil {
break
}
if time.Since(logged) > 1*time.Minute {
// #nosec G115
log.Info("Recreating missing states", "block", current, "target", target, "remaining", int64(target)-int64(current), "elapsed", time.Since(start), "recreated", recreated)
logged = time.Now()
}
currentState, err := state.New(currentBlock.Root(), database, nil)
if err != nil {
_, _, _, err := bc.Processor().Process(currentBlock, previousState, vm.Config{})
if err != nil {
return fmt.Errorf("processing block %d failed: %w", current, err)
}
root, err := previousState.Commit(current, bc.Config().IsEIP158(currentBlock.Number()))
if err != nil {
return fmt.Errorf("StateDB commit failed, number %d root %v: %w", current, currentBlock.Root(), err)
}
if root.Cmp(currentBlock.Root()) != 0 {
return fmt.Errorf("reached different state root after processing block %d, have %v, want %v", current, root, currentBlock.Root())
}
// commit to disk
err = database.TrieDB().Commit(root, false)
if err != nil {
return fmt.Errorf("TrieDB commit failed, number %d root %v: %w", current, root, err)
}
currentState, err = state.New(currentBlock.Root(), database, nil)
if err != nil {
return fmt.Errorf("state reset after block %d failed: %w", current, err)
}
recreated++
}
current++
previousState = currentState
}
log.Info("Finished recreating missing states", "elapsed", time.Since(start), "recreated", recreated)
return nil
}
Binary file removed nitro-overrides/fheosdb/000002.ldb
Binary file not shown.
Empty file removed nitro-overrides/fheosdb/000051.log
Empty file.
1 change: 0 additions & 1 deletion nitro-overrides/fheosdb/CURRENT

This file was deleted.

1 change: 0 additions & 1 deletion nitro-overrides/fheosdb/CURRENT.bak

This file was deleted.

Loading
Loading