Skip to content

Commit

Permalink
Added changes to make state transitioner work (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts authored Dec 3, 2020
1 parent d824abc commit 3273df8
Show file tree
Hide file tree
Showing 7 changed files with 412 additions and 485 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
import { Lib_EthUtils } from "../../libraries/utils/Lib_EthUtils.sol";
import { Lib_SecureMerkleTrie } from "../../libraries/trie/Lib_SecureMerkleTrie.sol";
import { Lib_RLPWriter } from "../../libraries/rlp/Lib_RLPWriter.sol";
import { Lib_RLPReader } from "../../libraries/rlp/Lib_RLPReader.sol";

/* Interface Imports */
import { iOVM_StateTransitioner } from "../../iOVM/verification/iOVM_StateTransitioner.sol";
Expand Down Expand Up @@ -266,13 +268,15 @@ contract OVM_StateTransitioner is Lib_AddressResolver, OVM_FraudContributor, iOV

(
bool exists,
bytes memory value
bytes memory encodedValue
) = Lib_SecureMerkleTrie.get(
abi.encodePacked(_key),
_storageTrieWitness,
ovmStateManager.getAccountStorageRoot(_ovmContractAddress)
);

bytes memory value = Lib_RLPReader.readBytes(encodedValue);

if (exists == true) {
require(
keccak256(value) == keccak256(abi.encodePacked(_value)),
Expand Down Expand Up @@ -393,7 +397,9 @@ contract OVM_StateTransitioner is Lib_AddressResolver, OVM_FraudContributor, iOV

account.storageRoot = Lib_SecureMerkleTrie.update(
abi.encodePacked(_key),
abi.encodePacked(value),
Lib_RLPWriter.writeBytes(
abi.encodePacked(value)
),
_storageTrieWitness,
account.storageRoot
);
Expand Down
12 changes: 2 additions & 10 deletions packages/contracts/test/bond.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,7 @@ describe('BondManager', () => {

// a dispute is created about a block that intersects
const disputeTimestamp = withdrawalTimestamp - 100
await fraudVerifier.finalize(
preStateRoot,
sender,
disputeTimestamp
)
await fraudVerifier.finalize(preStateRoot, sender, disputeTimestamp)

await mineBlock(deployer.provider, timestamp)
await expect(bondManager.finalizeWithdrawal()).to.be.revertedWith(
Expand All @@ -321,11 +317,7 @@ describe('BondManager', () => {
// a dispute is created, but since the fraud period is already over
// it doesn't matter
const disputeTimestamp = withdrawalTimestamp - ONE_WEEK - 1
await fraudVerifier.finalize(
preStateRoot,
sender,
disputeTimestamp
)
await fraudVerifier.finalize(preStateRoot, sender, disputeTimestamp)

const finalizeWithdrawalTimestamp = withdrawalTimestamp + ONE_WEEK
await mineBlock(deployer.provider, finalizeWithdrawalTimestamp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ describe('OVM_ECDSAContractAccount', () => {
it(`should revert on incorrect chainId`, async () => {
const alteredChainIdTx = {
...DEFAULT_EIP155_TX,
chainId : 421
chainId: 421,
}
const message = serializeNativeTransaction(alteredChainIdTx)
const sig = await signNativeTransaction(wallet, alteredChainIdTx)
Expand Down
Loading

0 comments on commit 3273df8

Please sign in to comment.