-
Notifications
You must be signed in to change notification settings - Fork 11
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
Showing
12 changed files
with
323 additions
and
31 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
61 changes: 61 additions & 0 deletions
61
executor/extension/validator/ethereum_post_transaction_updator.go
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,61 @@ | ||
// Copyright 2024 Fantom Foundation | ||
// This file is part of Aida Testing Infrastructure for Sonic | ||
// | ||
// Aida is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aida is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aida. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package validator | ||
|
||
import ( | ||
"github.com/Fantom-foundation/Aida/executor" | ||
"github.com/Fantom-foundation/Aida/executor/extension" | ||
"github.com/Fantom-foundation/Aida/logger" | ||
"github.com/Fantom-foundation/Aida/txcontext" | ||
"github.com/Fantom-foundation/Aida/utils" | ||
) | ||
|
||
// MakeEthereumDbPostTransactionUpdator creates an extension which fixes Ethereum exceptions in LiveDB | ||
func MakeEthereumDbPostTransactionUpdator(cfg *utils.Config) executor.Extension[txcontext.TxContext] { | ||
if cfg.ChainID != utils.EthereumChainID { | ||
return extension.NilExtension[txcontext.TxContext]{} | ||
} | ||
|
||
log := logger.NewLogger(cfg.LogLevel, "Ethereum-Exception-Updator") | ||
|
||
return makeEthereumDbPostTransactionUpdator(cfg, log) | ||
} | ||
|
||
func makeEthereumDbPostTransactionUpdator(cfg *utils.Config, log logger.Logger) executor.Extension[txcontext.TxContext] { | ||
return ðereumDbPostTransactionUpdater{ | ||
cfg: cfg, | ||
log: log, | ||
} | ||
} | ||
|
||
// PostTransaction fixes OutputAlloc ethereum exceptions in given substate | ||
func (v *ethereumDbPostTransactionUpdater) PostTransaction(state executor.State[txcontext.TxContext], ctx *executor.Context) error { | ||
return updateEthereumDb(state, ctx.State, false) | ||
} | ||
|
||
type ethereumDbPostTransactionUpdater struct { | ||
extension.NilExtension[txcontext.TxContext] | ||
cfg *utils.Config | ||
log logger.Logger | ||
} | ||
|
||
// PreRun informs the user that ethereumExceptionUpdator is enabled. | ||
func (v *ethereumDbPostTransactionUpdater) PreRun(executor.State[txcontext.TxContext], *executor.Context) error { | ||
v.log.Warning("Ethereum exception post transaction updator is enabled.") | ||
|
||
return nil | ||
} |
61 changes: 61 additions & 0 deletions
61
executor/extension/validator/ethereum_pre_transaction_updator.go
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,61 @@ | ||
// Copyright 2024 Fantom Foundation | ||
// This file is part of Aida Testing Infrastructure for Sonic | ||
// | ||
// Aida is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Aida is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with Aida. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package validator | ||
|
||
import ( | ||
"github.com/Fantom-foundation/Aida/executor" | ||
"github.com/Fantom-foundation/Aida/executor/extension" | ||
"github.com/Fantom-foundation/Aida/logger" | ||
"github.com/Fantom-foundation/Aida/txcontext" | ||
"github.com/Fantom-foundation/Aida/utils" | ||
) | ||
|
||
// MakeEthereumDbPreTransactionUpdator creates an extension which fixes Ethereum exceptions in pre transaction in LiveDB | ||
func MakeEthereumDbPreTransactionUpdator(cfg *utils.Config) executor.Extension[txcontext.TxContext] { | ||
if cfg.ChainID != utils.EthereumChainID { | ||
return extension.NilExtension[txcontext.TxContext]{} | ||
} | ||
|
||
log := logger.NewLogger(cfg.LogLevel, "Ethereum-Exception-Updator") | ||
|
||
return makeEthereumDbPreTransactionUpdator(cfg, log) | ||
} | ||
|
||
func makeEthereumDbPreTransactionUpdator(cfg *utils.Config, log logger.Logger) executor.Extension[txcontext.TxContext] { | ||
return ðereumDbPreTransactionUpdator{ | ||
cfg: cfg, | ||
log: log, | ||
} | ||
} | ||
|
||
// PreTransaction validates fixes InputSubstate ethereum exceptions in given substate | ||
func (v *ethereumDbPreTransactionUpdator) PreTransaction(state executor.State[txcontext.TxContext], ctx *executor.Context) error { | ||
return updateEthereumDb(state, ctx.State, true) | ||
} | ||
|
||
type ethereumDbPreTransactionUpdator struct { | ||
extension.NilExtension[txcontext.TxContext] | ||
cfg *utils.Config | ||
log logger.Logger | ||
} | ||
|
||
// PreRun informs the user that ethereumExceptionUpdator is enabled. | ||
func (v *ethereumDbPreTransactionUpdator) PreRun(executor.State[txcontext.TxContext], *executor.Context) error { | ||
v.log.Warning("Ethereum exception pre transaction updator is enabled.") | ||
|
||
return nil | ||
} |
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
Oops, something went wrong.