Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit f5dc02c
Author: Kirill <[email protected]>
Date:   Thu Oct 17 11:15:15 2024 +0400

    Small restructure of plugin logic (#2221)

commit b43c46f
Author: Rian Hughes <[email protected]>
Date:   Wed Oct 16 15:42:07 2024 +0300

    Support plugins (#2051)

    Co-authored-by: rian <[email protected]>
    Co-authored-by: LordGhostX <[email protected]>

commit ca006de
Author: Kirill <[email protected]>
Date:   Wed Oct 16 16:14:16 2024 +0400

    Replace UnmarshalJSON() with UnmarshalText() for transaction statuses (#2220)

    * Replace UnmarshalJSON() with UnmarshalText() for transaction statuses

    UnmarshalText avoids issues with forgetting quotes in JSON, making it simpler for parsing plain text values.

fix merge conflicts
  • Loading branch information
weiihann committed Oct 17, 2024
1 parent 95e6b9c commit bbbb4f8
Show file tree
Hide file tree
Showing 18 changed files with 676 additions and 153 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ After following these steps, Juno should be up and running on your machine, util
- Starknet state construction and storage using a path-based Merkle Patricia trie.
- Feeder gateway synchronisation of Blocks, Transactions, Receipts, State Updates and Classes.
- Block and Transaction hash verification.
- Plugins

## 🛣 Roadmap

Expand Down
18 changes: 17 additions & 1 deletion blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,23 @@ func (b *Blockchain) RevertHead() error {
return b.database.Update(b.revertHead)
}

func (b *Blockchain) GetReverseStateDiff() (*core.StateDiff, error) {
var reverseStateDiff *core.StateDiff
return reverseStateDiff, b.database.View(func(txn db.Transaction) error {
blockNumber, err := chainHeight(txn)
if err != nil {
return err
}
stateUpdate, err := stateUpdateByNumber(txn, blockNumber)
if err != nil {
return err
}
state := core.NewState(txn)
reverseStateDiff, err = state.GetReverseStateDiff(blockNumber, stateUpdate.StateDiff)
return err
})
}

func (b *Blockchain) revertHead(txn db.Transaction) error {
blockNumber, err := chainHeight(txn)
if err != nil {
Expand Down Expand Up @@ -874,7 +891,6 @@ func (b *Blockchain) revertHead(txn db.Transaction) error {
}

// Revert chain height and pending.

if genesisBlock {
if err = txn.Delete(db.Pending.Key()); err != nil {
return err
Expand Down
4 changes: 4 additions & 0 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const (
callMaxStepsF = "rpc-call-max-steps"
corsEnableF = "rpc-cors-enable"
versionedConstantsFileF = "versioned-constants-file"
pluginPathF = "plugin-path"

defaultConfig = ""
defaulHost = "localhost"
Expand Down Expand Up @@ -119,6 +120,7 @@ const (
defaultGwTimeout = 5 * time.Second
defaultCorsEnable = false
defaultVersionedConstantsFile = ""
defaultPluginPath = ""

configFlagUsage = "The YAML configuration file."
logLevelFlagUsage = "Options: trace, debug, info, warn, error."
Expand Down Expand Up @@ -170,6 +172,7 @@ const (
"The upper limit is 4 million steps, and any higher value will still be capped at 4 million."
corsEnableUsage = "Enable CORS on RPC endpoints"
versionedConstantsFileUsage = "Use custom versioned constants from provided file"
pluginPathUsage = "Path to the plugin .so file"
)

var Version string
Expand Down Expand Up @@ -355,6 +358,7 @@ func NewCmd(config *node.Config, run func(*cobra.Command, []string) error) *cobr
junoCmd.Flags().Bool(corsEnableF, defaultCorsEnable, corsEnableUsage)
junoCmd.Flags().String(versionedConstantsFileF, defaultVersionedConstantsFile, versionedConstantsFileUsage)
junoCmd.MarkFlagsMutuallyExclusive(p2pFeederNodeF, p2pPeersF)
junoCmd.Flags().String(pluginPathF, defaultPluginPath, pluginPathUsage)

junoCmd.AddCommand(GenP2PKeyPair(), DBCmd(defaultDBPath))

Expand Down
Loading

0 comments on commit bbbb4f8

Please sign in to comment.