-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rian
committed
Aug 14, 2024
1 parent
dc46ab3
commit c08159a
Showing
8 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package junoplugin | ||
|
||
import ( | ||
"fmt" | ||
"plugin" | ||
|
||
"github.com/NethermindEth/juno/core" | ||
"github.com/NethermindEth/juno/core/felt" | ||
) | ||
|
||
//go:generate mockgen -destination=../mocks/mock_plugin.go -package=mocks github.com/NethermindEth/juno/plugin JunoPlugin | ||
type JunoPlugin interface { | ||
Init() error | ||
Shutdown() error // Todo: Currently this function will never be called. | ||
NewBlock(block *core.Block, stateUpdate *core.StateUpdate, newClasses map[felt.Felt]core.Class) error | ||
// The state is reverted by applying a write operation with the reverseStateDiff's StorageDiffs, Nonces, and ReplacedClasses, | ||
// and a delete option with its DeclaredV0Classes, DeclaredV1Classes, and ReplacedClasses. | ||
RevertBlock(from, to *BlockAndStateUpdate, reverseStateDiff *core.StateDiff) error | ||
} | ||
|
||
type BlockAndStateUpdate struct { | ||
Block *core.Block | ||
StateUpdate *core.StateUpdate | ||
} | ||
|
||
func Load(pluginPath string) (JunoPlugin, error) { | ||
plug, err := plugin.Open(pluginPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("error loading plugin .so file: %w", err) | ||
} | ||
|
||
symPlugin, err := plug.Lookup("JunoPluginInstance") | ||
if err != nil { | ||
return nil, fmt.Errorf("error looking up PluginInstance: %w", err) | ||
} | ||
|
||
pluginInstance, ok := symPlugin.(JunoPlugin) | ||
if !ok { | ||
return nil, fmt.Errorf("the plugin does not staisfy the required interface") | ||
} | ||
|
||
return pluginInstance, pluginInstance.Init() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters